forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPclExportClient.WinStore.cs
More file actions
67 lines (55 loc) · 1.8 KB
/
PclExportClient.WinStore.cs
File metadata and controls
67 lines (55 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//Copyright (c) Service Stack LLC. All Rights Reserved.
//License: https://raw.github.com/ServiceStack/ServiceStack/master/license.txt
#if NETFX_CORE
using System;
using System.Threading;
using ServiceStack.Pcl;
using ServiceStack.Web;
using Windows.System.Threading;
namespace ServiceStack
{
public class WinStorePclExportClient : PclExportClient
{
public static WinStorePclExportClient Provider = new WinStorePclExportClient();
public static PclExportClient Configure()
{
Configure(Provider ?? (Provider = new WinStorePclExportClient()));
WinStorePclExport.Configure();
return Provider;
}
public override INameValueCollection NewNameValueCollection()
{
return new NameValueCollectionWrapper(new NameValueCollection());
}
public override INameValueCollection ParseQueryString(string query)
{
return HttpUtility.ParseQueryString(query).InWrapper();
}
public override ITimer CreateTimer(TimerCallback cb, TimeSpan timeOut, object state)
{
return new WinStoreAsyncTimer(ThreadPoolTimer.CreateTimer(s => cb(s), timeOut));
}
public override void RunOnUiThread(Action fn)
{
Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
Windows.UI.Core.CoreDispatcherPriority.Normal, () => fn());
}
}
public class WinStoreAsyncTimer : ITimer
{
public ThreadPoolTimer Timer;
public WinStoreAsyncTimer(ThreadPoolTimer timer)
{
Timer = timer;
}
public void Cancel()
{
this.Timer.Cancel();
}
public void Dispose()
{
this.Timer = null;
}
}
}
#endif