diff options
Diffstat (limited to 'StoneIsland/plugins/cordova-plugin-customurlscheme/src/wp8/CompositeUriMapper.cs')
| -rw-r--r-- | StoneIsland/plugins/cordova-plugin-customurlscheme/src/wp8/CompositeUriMapper.cs | 46 |
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 |
