cude cd

public virtual Assembly[] GetAssemblies()
		{
			var options = new QueryOptions { FileTypeFilter = { ".exe", ".dll" } };

			StorageFileQueryResult query = Package.Current.InstalledLocation.CreateFileQueryWithOptions(options);
			IReadOnlyList<StorageFile> files = query.GetFilesAsync().AsTask().Result;

			var assemblies = new List<Assembly>(files.Count);
			foreach (StorageFile file in files)
			{
				try
				{
					Assembly assembly = Assembly.Load(new AssemblyName { Name = IOPath.GetFileNameWithoutExtension(file.Name) });

					assemblies.Add(assembly);
				}
				catch (IOException)
				{
				}
				catch (BadImageFormatException)
				{
				}
			}

			Assembly thisAssembly = GetType().GetTypeInfo().Assembly;
			// this happens with .NET Native
			if (!assemblies.Contains(thisAssembly))
				assemblies.Add(thisAssembly);

			Assembly coreAssembly = typeof(Xamarin.Forms.Label).GetTypeInfo().Assembly;
			if (!assemblies.Contains(coreAssembly))
				assemblies.Add(coreAssembly);

			Assembly xamlAssembly = typeof(Xamarin.Forms.Xaml.Extensions).GetTypeInfo().Assembly;
			if (!assemblies.Contains(xamlAssembly))
				assemblies.Add(xamlAssembly);

			return assemblies.ToArray();
		}
		
		
		
		
		using System;
using System.Reflection;
using System.Runtime.InteropServices;

namespace Xamarin.Forms.Platform.UAP
{
	/// <summary>
	/// Enables C++ code to simulate ICLRRuntimeHost2::ExecuteAssembly on top of ICLRRuntimeHost2::CreateDelegate in .net core 2.
	/// </summary>
	static class BootstrapHelper
	{

		// Do not overload this method. ICLRRuntimeHost2::CreateDelegate can not resolve overloaded methods.
		[PreserveSig]
		private static int Bootstrap(
			[MarshalAs(UnmanagedType.LPWStr)] string assemblyPath,
			[MarshalAs(UnmanagedType.LPWStr)] string typeName,
			[MarshalAs(UnmanagedType.LPWStr)] string methodName,
			[MarshalAs(UnmanagedType.LPWStr)] string argument)
		{
			try
			{
				MethodInfo loadFrom = typeof(Assembly).GetMethod("LoadFrom", new Type[] { typeof(string) });
				if (loadFrom == null)
				{
					// LoadFrom is only available in .net core 2.0 and later. Since the target
					// assembly isn't in the normal load path there isn't anything we can do.
					throw new PlatformNotSupportedException();
				}

				Assembly assembly = (Assembly)loadFrom.Invoke(null, new object[] { assemblyPath });
				Type type = assembly.GetType(typeName);
				MethodInfo method = type.GetMethod(methodName);
				method.Invoke(null, new object[] { argument });
				return 0;
			}
			catch (Exception ex)
			{
				return ex.HResult;
			}
		}
	}
}



	public void Navigate(string uri)
		{
			Uri uriResult;
			bool result = Uri.TryCreate(uri, UriKind.Absolute, out uriResult)
				&& (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps);

			if (result)
			{
				_browser.Navigate(new Uri(uri));
			}
			else
			{
				string appPath = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
				string filePath = System.IO.Path.Combine(appPath, uri);
				_browser.Url = new Uri(filePath);
			}
		}


static Assembly _assembly;
		static Type FindType(string name, string altName)
		{
			return _assembly?.GetTypes().FirstOrDefault(x => x.Name == name || x.Name == altName);
		}


	static Type _drawableClass;
		static Type _resourceClass;
		static Type _styleClass;
		static Type _layoutClass;

		public static Type DrawableClass
		{
			get
			{
				if (_drawableClass == null)
					_drawableClass = FindType("Drawable", "Resource_Drawable");
				return _drawableClass;
			}
			set
			{
				_drawableClass = value;
			}
		}

		public static Type ResourceClass
		{
			get
			{
				if (_resourceClass == null)
					_resourceClass = FindType("Id", "Resource_Id");
				return _resourceClass;
			}
			set
			{
				_resourceClass = value;
			}
		}

		public static Type StyleClass
		{
			get
			{
				if (_styleClass == null)
					_styleClass = FindType("Style", "Resource_Style");
				return _styleClass;
			}
			set
			{
				_styleClass = value;
			}
		}

		public static Type LayoutClass
		{
			get
			{
				if (_layoutClass == null)
					_layoutClass = FindType("Layout", "Resource_Layout");
				return _layoutClass;
			}
			set
			{
				_layoutClass = value;
			}
		}

		
		
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Farmwang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值