This repository has been archived by the owner on Dec 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 633
/
PclExport.WP.cs
57 lines (49 loc) · 1.53 KB
/
PclExport.WP.cs
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
//Copyright (c) Service Stack LLC. All Rights Reserved.
//License: https://raw.github.com/ServiceStack/ServiceStack/master/license.txt
#if WP
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.IsolatedStorage;
using System.Linq;
using System.Reflection;
namespace ServiceStack
{
public class WpPclExport : PclExport
{
public static WpPclExport Provider = new WpPclExport();
public WpPclExport()
{
this.PlatformName = "WindowsPhone";
}
public static PclExport Configure()
{
Configure(Provider);
return Provider;
}
public override string ReadAllText(string filePath)
{
using (var isoStore = IsolatedStorageFile.GetUserStoreForApplication())
{
using (var fileStream = isoStore.OpenFile(filePath, FileMode.Open))
{
return new StreamReader(fileStream).ReadToEnd();
}
}
}
public override Assembly LoadAssembly(string assemblyPath)
{
return Assembly.LoadFrom(assemblyPath);
}
public override string GetAssemblyCodeBase(Assembly assembly)
{
return assembly.GetName().CodeBase;
}
public override Type GetGenericCollectionType(Type type)
{
return type.GetInterfaces()
.FirstOrDefault(t => t.IsGenericType && t.GetGenericTypeDefinition() == typeof(ICollection<>));
}
}
}
#endif