summaryrefslogtreecommitdiff
path: root/StoneIsland/plugins/cordova-plugin-customurlscheme/src/wp8/CompositeUriMapper.cs
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2016-11-08 12:37:03 -0500
committerJules Laplace <jules@okfoc.us>2016-11-08 12:37:03 -0500
commitef4f212fc1482136dba1e690ec589b315b4a377f (patch)
tree0b7e16d72567fafcfd3e08d7c5c591ad07a63458 /StoneIsland/plugins/cordova-plugin-customurlscheme/src/wp8/CompositeUriMapper.cs
parent5fa81da81260d65113f57a293b6256d334fe8e2d (diff)
build 0.7.0
Diffstat (limited to 'StoneIsland/plugins/cordova-plugin-customurlscheme/src/wp8/CompositeUriMapper.cs')
-rw-r--r--StoneIsland/plugins/cordova-plugin-customurlscheme/src/wp8/CompositeUriMapper.cs46
1 files changed, 46 insertions, 0 deletions
diff --git a/StoneIsland/plugins/cordova-plugin-customurlscheme/src/wp8/CompositeUriMapper.cs b/StoneIsland/plugins/cordova-plugin-customurlscheme/src/wp8/CompositeUriMapper.cs
new file mode 100644
index 00000000..8db593b8
--- /dev/null
+++ b/StoneIsland/plugins/cordova-plugin-customurlscheme/src/wp8/CompositeUriMapper.cs
@@ -0,0 +1,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;
+ }
+} \ No newline at end of file