diff options
author | Jason Smith <jason.smith@xamarin.com> | 2016-03-22 13:02:25 -0700 |
---|---|---|
committer | Jason Smith <jason.smith@xamarin.com> | 2016-03-22 16:13:41 -0700 |
commit | 17fdde66d94155fc62a034fa6658995bef6fd6e5 (patch) | |
tree | b5e5073a2a7b15cdbe826faa5c763e270a505729 /Xamarin.Forms.Platform.WinRT.Phone/WindowsPhonePlatformServices.cs | |
download | xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.tar.gz xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.tar.bz2 xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.zip |
Initial import
Diffstat (limited to 'Xamarin.Forms.Platform.WinRT.Phone/WindowsPhonePlatformServices.cs')
-rw-r--r-- | Xamarin.Forms.Platform.WinRT.Phone/WindowsPhonePlatformServices.cs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.WinRT.Phone/WindowsPhonePlatformServices.cs b/Xamarin.Forms.Platform.WinRT.Phone/WindowsPhonePlatformServices.cs new file mode 100644 index 00000000..37d2d4fb --- /dev/null +++ b/Xamarin.Forms.Platform.WinRT.Phone/WindowsPhonePlatformServices.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using Windows.ApplicationModel; +using Windows.Storage; +using Windows.UI.Core; + +namespace Xamarin.Forms.Platform.WinRT +{ + internal class WindowsPhonePlatformServices + : WindowsBasePlatformServices + { + public WindowsPhonePlatformServices (CoreDispatcher dispatcher) + : base (dispatcher) + { + } + + public override Assembly[] GetAssemblies() + { + var files = Package.Current.InstalledLocation.GetFilesAsync().AsTask().Result; + + List<Assembly> assemblies = new List<Assembly> (files.Count); + for (int i = 0; i < files.Count; i++) { + StorageFile file = files[i]; + if (file.Name.Length < 3) + continue; + + string extension = file.Name.Substring (file.Name.Length - 3, 3).ToLower(); + if (extension != "dll" && extension != "exe") + continue; + + try { + Assembly assembly = Assembly.Load (new AssemblyName { Name = Path.GetFileNameWithoutExtension (file.Name) }); + assemblies.Add (assembly); + } catch (IOException) { + } catch (BadImageFormatException) { + } + } + + return assemblies.ToArray(); + } + } +}
\ No newline at end of file |