当前位置: 首页>>代码示例>>C#>>正文


C# ModuleScope.LoadAssemblyIntoCache方法代码示例

本文整理汇总了C#中ModuleScope.LoadAssemblyIntoCache方法的典型用法代码示例。如果您正苦于以下问题:C# ModuleScope.LoadAssemblyIntoCache方法的具体用法?C# ModuleScope.LoadAssemblyIntoCache怎么用?C# ModuleScope.LoadAssemblyIntoCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ModuleScope的用法示例。


在下文中一共展示了ModuleScope.LoadAssemblyIntoCache方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckLoadAssemblyIntoCache

		private void CheckLoadAssemblyIntoCache(ProxyCreator creator)
		{
			var savedScope = new ModuleScope(true);
			var builder = new DefaultProxyBuilder(savedScope);

			var cp = creator(builder);
			Assert.AreSame(cp, creator(builder));

			var path = savedScope.SaveAssembly();

			CrossAppDomainCaller.RunInOtherAppDomain(delegate(object[] args)
			                                         	{
			                                         		var newScope = new ModuleScope(false);
			                                         		var newBuilder = new DefaultProxyBuilder(newScope);

			                                         		var assembly = Assembly.LoadFrom((string) args[0]);
			                                         		newScope.LoadAssemblyIntoCache(assembly);

			                                         		var loadedCP = assembly.GetType((string) args[1]);
			                                         		Assert.AreSame(loadedCP, ((ProxyCreator) args[2])(newBuilder));
			                                         		Assert.AreEqual(assembly, ((ProxyCreator) args[2])(newBuilder).Assembly);
			                                         	}, path, cp.FullName, creator);

			File.Delete(path);
		}
开发者ID:jeremymeng,项目名称:Core,代码行数:25,代码来源:ModuleScopeTestCase.cs

示例2: LoadAssemblyIntoCache_InvalidAssembly

		public void LoadAssemblyIntoCache_InvalidAssembly()
		{
			var newScope = new ModuleScope(false);

			Assert.Throws<ArgumentException>(() =>
				newScope.LoadAssemblyIntoCache(Assembly.GetExecutingAssembly())
			);
		}
开发者ID:jeremymeng,项目名称:Core,代码行数:8,代码来源:ModuleScopeTestCase.cs

示例3: LoadAssemblyIntoCache_DifferentGenerationOptions

		public void LoadAssemblyIntoCache_DifferentGenerationOptions()
		{
			var savedScope = new ModuleScope(true);
			var builder = new DefaultProxyBuilder(savedScope);

			var options1 = new ProxyGenerationOptions();
			options1.AddMixinInstance(new DateTime());
			var options2 = ProxyGenerationOptions.Default;

			var cp1 = builder.CreateClassProxyType(typeof (object), Type.EmptyTypes, options1);
			var cp2 = builder.CreateClassProxyType(typeof (object), Type.EmptyTypes, options2);
			Assert.AreNotSame(cp1, cp2);
			Assert.AreSame(cp1, builder.CreateClassProxyType(typeof (object), Type.EmptyTypes, options1));
			Assert.AreSame(cp2, builder.CreateClassProxyType(typeof (object), Type.EmptyTypes, options2));

			var path = savedScope.SaveAssembly();

			CrossAppDomainCaller.RunInOtherAppDomain(delegate(object[] args)
			                                         	{
			                                         		var newScope = new ModuleScope(false);
			                                         		var newBuilder = new DefaultProxyBuilder(newScope);

			                                         		var assembly = Assembly.LoadFrom((string) args[0]);
			                                         		newScope.LoadAssemblyIntoCache(assembly);

			                                         		var newOptions1 = new ProxyGenerationOptions();
			                                         		newOptions1.AddMixinInstance(new DateTime());
			                                         		var newOptions2 = ProxyGenerationOptions.Default;

			                                         		var loadedCP1 = newBuilder.CreateClassProxyType(typeof (object),
			                                         		                                                Type.EmptyTypes,
			                                         		                                                newOptions1);
			                                         		var loadedCP2 = newBuilder.CreateClassProxyType(typeof (object),
			                                         		                                                Type.EmptyTypes,
			                                         		                                                newOptions2);
			                                         		Assert.AreNotSame(loadedCP1, loadedCP2);
			                                         		Assert.AreEqual(assembly, loadedCP1.Assembly);
			                                         		Assert.AreEqual(assembly, loadedCP2.Assembly);
			                                         	}, path);

			File.Delete(path);
		}
开发者ID:jeremymeng,项目名称:Core,代码行数:42,代码来源:ModuleScopeTestCase.cs

示例4: LoadAssemblyIntoCache_InvalidAssembly

		public void LoadAssemblyIntoCache_InvalidAssembly()
		{
			var newScope = new ModuleScope(false);
			newScope.LoadAssemblyIntoCache(Assembly.GetExecutingAssembly());
		}
开发者ID:leloulight,项目名称:Core,代码行数:5,代码来源:ModuleScopeTestCase.cs


注:本文中的ModuleScope.LoadAssemblyIntoCache方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。