blob: 8db593b84fd7d266d89b151e309ddb340a70ac3e (
plain)
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
|
using System;
using System.Linq;
using System.Windows.Navigation;
internal class CompositeUriMapper : UriMapperBase
{
public static string launchUrl;
public override Uri MapUri(Uri uri)
{
string launchUri = uri.ToString();
if (launchUri.StartsWith("/Protocol?encodedLaunchUri="))
{
int launchUrlIndex = launchUri.IndexOf("encodedLaunchUri=");
launchUrl = System.Net.HttpUtility.UrlDecode(launchUri.Substring(launchUrlIndex+17));
return new Uri("/MainPage.xaml", UriKind.Relative);
}
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
var types = assemblies.SelectMany(a =>
{
try
{
return a.ExportedTypes.Where(et => typeof(ICustomUriMapper).IsAssignableFrom(et));
}
catch
{
return Enumerable.Empty<Type>();
}
});
foreach (var type in types)
{
if (type != typeof(ICustomUriMapper))
{
var worker = (ICustomUriMapper)Activator.CreateInstance(type);
var mappedUri = worker.CustomMapUri(uri);
if (mappedUri != null)
{
return mappedUri;
}
}
}
return uri;
}
}
|