Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions MADE.App.Networking/NetworkRequestManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ namespace MADE.App.Networking
/// </summary>
public sealed class NetworkRequestManager : INetworkRequestManager
{
#if WINDOWS_UWP
private readonly Windows.UI.Xaml.DispatcherTimer processTimer;
#else
private Timer processTimer;
#endif

private bool isProcessingRequests;

Expand All @@ -37,11 +33,6 @@ public sealed class NetworkRequestManager : INetworkRequestManager
public NetworkRequestManager()
{
this.CurrentQueue = new ConcurrentDictionary<string, NetworkRequestCallback>();

#if WINDOWS_UWP
this.processTimer = new Windows.UI.Xaml.DispatcherTimer { Interval = TimeSpan.FromMinutes(1) };
this.processTimer.Tick += (sender, o) => this.ProcessCurrentQueue();
#endif
}

/// <summary>
Expand All @@ -65,14 +56,6 @@ public void Start()
/// </param>
public void Start(TimeSpan processPeriod)
{
#if WINDOWS_UWP
this.processTimer.Interval = processPeriod;

if (!this.processTimer.IsEnabled)
{
this.processTimer.Start();
}
#else
if (this.processTimer == null)
{
this.processTimer = new Timer(
Expand All @@ -85,22 +68,14 @@ public void Start(TimeSpan processPeriod)
{
this.processTimer.Change(TimeSpan.FromMinutes(0), processPeriod);
}
#endif
}

/// <summary>
/// Stops the processing of the network manager queues.
/// </summary>
public void Stop()
{
#if WINDOWS_UWP
if (this.processTimer.IsEnabled)
{
this.processTimer.Stop();
}
#else
this.processTimer?.Change(Timeout.InfiniteTimeSpan, Timeout.InfiniteTimeSpan);
#endif
}

/// <summary>
Expand Down
22 changes: 0 additions & 22 deletions MADE.App.Networking/Requests/Json/JsonDeleteNetworkRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,13 @@

namespace MADE.App.Networking.Requests.Json
{
#if WINDOWS_UWP
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

using Windows.Web.Http;

using Newtonsoft.Json;

#else
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;

using Newtonsoft.Json;
#endif

/// <summary>
/// Defines a network request for a DELETE call with a JSON response.
Expand Down Expand Up @@ -128,15 +116,6 @@ private async Task<string> GetJsonResponse(CancellationTokenSource cts = null)
}
}

#if WINDOWS_UWP
HttpResponseMessage response = cts == null
? await this.client.SendRequestAsync(
request,
HttpCompletionOption.ResponseHeadersRead)
: await this.client.SendRequestAsync(
request,
HttpCompletionOption.ResponseHeadersRead).AsTask(cts.Token);
#else
HttpResponseMessage response = cts == null
? await this.client.SendAsync(
request,
Expand All @@ -145,7 +124,6 @@ private async Task<string> GetJsonResponse(CancellationTokenSource cts = null)
request,
HttpCompletionOption.ResponseHeadersRead,
cts.Token);
#endif

response.EnsureSuccessStatusCode();

Expand Down
22 changes: 0 additions & 22 deletions MADE.App.Networking/Requests/Json/JsonGetNetworkRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,13 @@

namespace MADE.App.Networking.Requests.Json
{
#if WINDOWS_UWP
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

using Windows.Web.Http;

using Newtonsoft.Json;

#else
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;

using Newtonsoft.Json;
#endif

/// <summary>
/// Defines a network request for a GET call with a JSON response.
Expand Down Expand Up @@ -128,15 +116,6 @@ private async Task<string> GetJsonResponse(CancellationTokenSource cts = null)
}
}

#if WINDOWS_UWP
HttpResponseMessage response = cts == null
? await this.client.SendRequestAsync(
request,
HttpCompletionOption.ResponseHeadersRead)
: await this.client.SendRequestAsync(
request,
HttpCompletionOption.ResponseHeadersRead).AsTask(cts.Token);
#else
HttpResponseMessage response = cts == null
? await this.client.SendAsync(
request,
Expand All @@ -145,7 +124,6 @@ private async Task<string> GetJsonResponse(CancellationTokenSource cts = null)
request,
HttpCompletionOption.ResponseHeadersRead,
cts.Token);
#endif

response.EnsureSuccessStatusCode();

Expand Down
35 changes: 19 additions & 16 deletions MADE.App.Networking/Requests/Json/JsonPatchNetworkRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@
// </summary>
// --------------------------------------------------------------------------------------------------------------------

#if WINDOWS_UWP
namespace MADE.App.Networking.Requests.Json
{
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

using Windows.Storage.Streams;
using Windows.Web.Http;

using MADE.App.Networking.Requests;

using Newtonsoft.Json;
Expand Down Expand Up @@ -142,13 +140,15 @@ private async Task<string> GetJsonResponse(CancellationTokenSource cts = null)

Uri uri = new Uri(this.Url);

HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Patch, uri)
{
Content = new HttpStringContent(
this.Data,
UnicodeEncoding.Utf8,
"application/json")
};
HttpRequestMessage request = new HttpRequestMessage
{
Method = new HttpMethod("PATCH"),
RequestUri = uri,
Content = new StringContent(
this.Data,
Encoding.UTF8,
"application/json")
};

if (this.Headers != null)
{
Expand All @@ -159,14 +159,17 @@ private async Task<string> GetJsonResponse(CancellationTokenSource cts = null)
}

HttpResponseMessage response = cts == null
? await this.client.SendRequestAsync(request, HttpCompletionOption.ResponseHeadersRead)
: await this.client.SendRequestAsync(request, HttpCompletionOption.ResponseHeadersRead)
.AsTask(cts.Token);
? await this.client.SendAsync(
request,
HttpCompletionOption.ResponseHeadersRead)
: await this.client.SendAsync(
request,
HttpCompletionOption.ResponseHeadersRead,
cts.Token);

response.EnsureSuccessStatusCode();

return await response.Content.ReadAsStringAsync();
}
}
}
#endif
}
36 changes: 0 additions & 36 deletions MADE.App.Networking/Requests/Json/JsonPostNetworkRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@

namespace MADE.App.Networking.Requests.Json
{
#if WINDOWS_UWP
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

using Windows.Storage.Streams;
using Windows.Web.Http;

using Newtonsoft.Json;

#else
using System;
using System.Collections.Generic;
using System.Net.Http;
Expand All @@ -30,8 +18,6 @@ namespace MADE.App.Networking.Requests.Json

using Newtonsoft.Json;

#endif

/// <summary>
/// Defines a network request for a POST call with a JSON response.
/// </summary>
Expand Down Expand Up @@ -152,17 +138,6 @@ private async Task<string> GetJsonResponse(CancellationTokenSource cts = null)

Uri uri = new Uri(this.Url);

#if WINDOWS_UWP

var request = new HttpRequestMessage(HttpMethod.Post, uri)
{
Content =
new HttpStringContent(
this.Data,
UnicodeEncoding.Utf8,
"application/json")
};
#else
HttpRequestMessage request =
new HttpRequestMessage(HttpMethod.Post, uri)
{
Expand All @@ -171,7 +146,6 @@ private async Task<string> GetJsonResponse(CancellationTokenSource cts = null)
Encoding.UTF8,
"application/json")
};
#endif

if (this.Headers != null)
{
Expand All @@ -181,15 +155,6 @@ private async Task<string> GetJsonResponse(CancellationTokenSource cts = null)
}
}

#if WINDOWS_UWP
HttpResponseMessage response = cts == null
? await this.client.SendRequestAsync(
request,
HttpCompletionOption.ResponseHeadersRead)
: await this.client.SendRequestAsync(
request,
HttpCompletionOption.ResponseHeadersRead).AsTask(cts.Token);
#else
HttpResponseMessage response = cts == null
? await this.client.SendAsync(
request,
Expand All @@ -198,7 +163,6 @@ private async Task<string> GetJsonResponse(CancellationTokenSource cts = null)
request,
HttpCompletionOption.ResponseHeadersRead,
cts.Token);
#endif

response.EnsureSuccessStatusCode();

Expand Down
Loading