• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ModuleScope类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: ClassProxyWithTargetTargetContributor

		public ClassProxyWithTargetTargetContributor(Type targetType, IList<MethodInfo> methodsToSkip,
		                                             INamingScope namingScope, ModuleScope scope)
			: base(namingScope, scope)
		{
			this.targetType = targetType;
			this.methodsToSkip = methodsToSkip;
		}
开发者ID:BiBongNet,项目名称:JustMockLite,代码行数:7,代码来源:ClassProxyWithTargetTargetContributor.cs


示例2: InterfaceProxyWithOptionalTargetContributor

        public InterfaceProxyWithOptionalTargetContributor(INamingScope namingScope, ModuleScope scope, GetTargetExpressionDelegate getTarget,
		                                                   GetTargetReferenceDelegate getTargetReference)
			: base(namingScope, scope, getTarget)
		{
			this.getTargetReference = getTargetReference;
			canChangeTarget = true;
		}
开发者ID:ArthurYiL,项目名称:JustMockLite,代码行数:7,代码来源:InterfaceProxyWithOptionalTargetContributor.cs


示例3: ModuleScopeCanHandleSignedAndUnsignedInParallel

		public void ModuleScopeCanHandleSignedAndUnsignedInParallel()
		{
			var scope = new ModuleScope();
			Assert.IsNull(scope.StrongNamedModule);
			Assert.IsNull(scope.WeakNamedModule);

			var one = scope.ObtainDynamicModuleWithStrongName();
			Assert.IsNotNull(scope.StrongNamedModule);
			Assert.IsNull(scope.WeakNamedModule);
			Assert.AreSame(one, scope.StrongNamedModule);

			var two = scope.ObtainDynamicModuleWithWeakName();
			Assert.IsNotNull(scope.StrongNamedModule);
			Assert.IsNotNull(scope.WeakNamedModule);
			Assert.AreSame(two, scope.WeakNamedModule);

			Assert.AreNotSame(one, two);
			Assert.AreNotSame(one.Assembly, two.Assembly);

			var three = scope.ObtainDynamicModuleWithStrongName();
			var four = scope.ObtainDynamicModuleWithWeakName();

			Assert.AreSame(one, three);
			Assert.AreSame(two, four);
		}
开发者ID:jeremymeng,项目名称:Core,代码行数:25,代码来源:ModuleScopeTestCase.cs


示例4: ModuleScopeStoresModuleBuilder

		public void ModuleScopeStoresModuleBuilder()
		{
			var scope = new ModuleScope();
			var one = scope.ObtainDynamicModuleWithStrongName();
			var two = scope.ObtainDynamicModuleWithStrongName();

			Assert.AreSame(one, two);
			Assert.AreSame(one.Assembly, two.Assembly);
		}
开发者ID:jeremymeng,项目名称:Core,代码行数:9,代码来源:ModuleScopeTestCase.cs


示例5: ClassProxyWithTargetGenerator

		public ClassProxyWithTargetGenerator(ModuleScope scope, Type classToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options)
			: base(scope, classToProxy)
		{
			CheckNotGenericTypeDefinition(targetType, "targetType");
			EnsureDoesNotImplementIProxyTargetAccessor(targetType, "targetType");
			CheckNotGenericTypeDefinitions(additionalInterfacesToProxy, "additionalInterfacesToProxy");

			options.Initialize();
			ProxyGenerationOptions = options;
			this.additionalInterfacesToProxy = TypeUtil.GetAllInterfaces(additionalInterfacesToProxy).ToArray();
		}
开发者ID:Orvid,项目名称:NAntUniversalTasks,代码行数:11,代码来源:ClassProxyWithTargetGenerator.cs


示例6: ImplicitModulePaths

		public void ImplicitModulePaths()
		{
			var scope = new ModuleScope(true);
			Assert.AreEqual(ModuleScope.DEFAULT_FILE_NAME, scope.StrongNamedModuleName);
			Assert.AreEqual(Path.Combine(Directory.GetCurrentDirectory(), ModuleScope.DEFAULT_FILE_NAME),
			                scope.ObtainDynamicModuleWithStrongName().FullyQualifiedName);
			Assert.IsNull(scope.StrongNamedModuleDirectory);

			Assert.AreEqual(ModuleScope.DEFAULT_FILE_NAME, scope.WeakNamedModuleName);
			Assert.AreEqual(Path.Combine(Directory.GetCurrentDirectory(), ModuleScope.DEFAULT_FILE_NAME),
			                scope.ObtainDynamicModuleWithWeakName().FullyQualifiedName);
			Assert.IsNull(scope.WeakNamedModuleDirectory);
		}
开发者ID:jeremymeng,项目名称:Core,代码行数:13,代码来源:ModuleScopeTestCase.cs


示例7: ClassEmitter

        public ClassEmitter(ModuleScope modulescope, String name, Type baseType, Type[] interfaces, TypeAttributes flags, bool forceUnsigned)
            : base(CreateTypeBuilder (modulescope, name, baseType, interfaces, flags, forceUnsigned))
        {
            InitializeGenericArgumentsFromBases(ref baseType, ref interfaces);

            if (interfaces != null)
            {
                foreach(Type inter in interfaces)
                {
                    TypeBuilder.AddInterfaceImplementation(inter);
                }
            }

            TypeBuilder.SetParent(baseType);
        }
开发者ID:havard,项目名称:strongbind,代码行数:15,代码来源:ClassEmitter.cs


示例8: ExplicitModulePaths

		public void ExplicitModulePaths ()
		{
			ModuleScope scope = new ModuleScope (true, "Strong", "StrongModule.dll", "Weak", "WeakModule.dll");
			Assert.AreEqual ("StrongModule.dll", scope.StrongNamedModuleName);
			Assert.AreEqual (Path.Combine (Environment.CurrentDirectory, "StrongModule.dll"), scope.ObtainDynamicModuleWithStrongName ().FullyQualifiedName);
			Assert.IsNull (scope.StrongNamedModuleDirectory);

			Assert.AreEqual ("WeakModule.dll", scope.WeakNamedModuleName);
			Assert.AreEqual (Path.Combine (Environment.CurrentDirectory, "WeakModule.dll"), scope.ObtainDynamicModuleWithWeakName ().FullyQualifiedName);
			Assert.IsNull (scope.WeakNamedModuleDirectory);

			scope = new ModuleScope (true, "Strong", @"c:\Foo\StrongModule.dll", "Weak", @"d:\Bar\WeakModule.dll");
			Assert.AreEqual ("StrongModule.dll", scope.StrongNamedModuleName);
			Assert.AreEqual (@"c:\Foo\StrongModule.dll", scope.ObtainDynamicModuleWithStrongName ().FullyQualifiedName);
			Assert.AreEqual (@"c:\Foo", scope.StrongNamedModuleDirectory);

			Assert.AreEqual ("WeakModule.dll", scope.WeakNamedModuleName);
			Assert.AreEqual (@"d:\Bar\WeakModule.dll", scope.ObtainDynamicModuleWithWeakName ().FullyQualifiedName);
			Assert.AreEqual (@"d:\Bar", scope.WeakNamedModuleDirectory);
		}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:20,代码来源:ModuleScopeTestCase.cs


示例9: DefaultProxyBuilderWithSpecificScope

		public void DefaultProxyBuilderWithSpecificScope()
		{
			var scope = new ModuleScope(false);
			var builder = new DefaultProxyBuilder(scope);
			Assert.AreSame(scope, builder.ModuleScope);
		}
开发者ID:jeremymeng,项目名称:Core,代码行数:6,代码来源:ModuleScopeTestCase.cs


示例10: GeneratedAssembliesWithCustomName

		public void GeneratedAssembliesWithCustomName()
		{
			var scope = new ModuleScope(false,false, "Strong", "Module1.dll", "Weak", "Module2,dll");
			var strong = scope.ObtainDynamicModuleWithStrongName();
			var weak = scope.ObtainDynamicModuleWithWeakName();

			Assert.AreEqual("Strong", strong.Assembly.GetName().Name);
			Assert.AreEqual("Weak", weak.Assembly.GetName().Name);
		}
开发者ID:jeremymeng,项目名称:Core,代码行数:9,代码来源:ModuleScopeTestCase.cs


示例11: ModuleScopeDoesntTryToDeleteFromCurrentDirectory

		public void ModuleScopeDoesntTryToDeleteFromCurrentDirectory()
		{
			var moduleDirectory = Path.Combine(Directory.GetCurrentDirectory(), "GeneratedDlls");
			if (Directory.Exists(moduleDirectory))
				Directory.Delete(moduleDirectory, true);

			var strongModulePath = Path.Combine(moduleDirectory, "Strong.dll");
			var weakModulePath = Path.Combine(moduleDirectory, "Weak.dll");

			Directory.CreateDirectory(moduleDirectory);
			var scope = new ModuleScope(true, false, "Strong", strongModulePath, "Weak", weakModulePath);

			using (File.Create(Path.Combine(Directory.GetCurrentDirectory(), "Strong.dll")))
			{
				scope.ObtainDynamicModuleWithStrongName();
				scope.SaveAssembly(true); // this will throw if SaveAssembly tries to delete from the current directory
			}

			using (File.Create(Path.Combine(Directory.GetCurrentDirectory(), "Weak.dll")))
			{
				scope.ObtainDynamicModuleWithWeakName();
				scope.SaveAssembly(false); // this will throw if SaveAssembly tries to delete from the current directory
			}

			// Clean up the generated DLLs because the FileStreams are now closed
			Directory.Delete(moduleDirectory, true);
			File.Delete(Path.Combine(Directory.GetCurrentDirectory(), "Strong.dll"));
			File.Delete(Path.Combine(Directory.GetCurrentDirectory(), "Weak.dll"));
		}
开发者ID:jeremymeng,项目名称:Core,代码行数:29,代码来源:ModuleScopeTestCase.cs


示例12: CacheMappingsHoldTypes

		public void CacheMappingsHoldTypes()
		{
			var scope = new ModuleScope(true);
			var builder = new DefaultProxyBuilder(scope);
			var cp = builder.CreateClassProxyType(typeof (object), Type.EmptyTypes, ProxyGenerationOptions.Default);

			var savedPath = scope.SaveAssembly();

			CrossAppDomainCaller.RunInOtherAppDomain(delegate(object[] args)
			                                         	{
			                                         		var assembly = Assembly.LoadFrom((string) args[0]);
			                                         		var attribute =
			                                         			(CacheMappingsAttribute)
			                                         			assembly.GetCustomAttributes(typeof (CacheMappingsAttribute), false)[0];
			                                         		var entries = attribute.GetDeserializedMappings();
			                                         		Assert.AreEqual(1, entries.Count);

			                                         		var key = new CacheKey(typeof (object), new Type[0],
			                                         		                       ProxyGenerationOptions.Default);
			                                         		Assert.IsTrue(entries.ContainsKey(key));
			                                         		Assert.AreEqual(args[1], entries[key]);
			                                         	},
			                                         savedPath, cp.FullName);

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


示例13: GeneratedAssembliesDefaultName

		public void GeneratedAssembliesDefaultName()
		{
			var scope = new ModuleScope();
			var strong = scope.ObtainDynamicModuleWithStrongName();
			var weak = scope.ObtainDynamicModuleWithWeakName();

			Assert.AreEqual(ModuleScope.DEFAULT_ASSEMBLY_NAME, strong.Assembly.GetName().Name);
			Assert.AreEqual(ModuleScope.DEFAULT_ASSEMBLY_NAME, weak.Assembly.GetName().Name);
		}
开发者ID:jeremymeng,项目名称:Core,代码行数:9,代码来源:ModuleScopeTestCase.cs


示例14: BaseProxyGenerator

		protected BaseProxyGenerator(ModuleScope scope, Type targetType)
		{
			this.scope = scope;
			this.targetType = targetType;
		}
开发者ID:AGiorgetti,项目名称:Castle.Core,代码行数:5,代码来源:BaseProxyGenerator.cs


示例15: CreateTypeBuilder

		private static TypeBuilder CreateTypeBuilder(ModuleScope modulescope, string name, Type baseType, Type[] interfaces,
		                                             TypeAttributes flags, bool forceUnsigned)
		{
			bool isAssemblySigned = !forceUnsigned && !StrongNameUtil.IsAnyTypeFromUnsignedAssembly(baseType, interfaces);
			return modulescope.ObtainDynamicModule(isAssemblySigned).DefineType(name, flags);
		}
开发者ID:ralescano,项目名称:castle,代码行数:6,代码来源:ClassEmitter.cs


示例16: ClassProxyGenerator

		public ClassProxyGenerator(ModuleScope scope, Type targetType) : base(scope, targetType)
		{
			CheckNotGenericTypeDefinition(targetType, "targetType");
			EnsureDoesNotImplementIProxyTargetAccessor(targetType, "targetType");
		}
开发者ID:elevine,项目名称:Core,代码行数:5,代码来源:ClassProxyGenerator.cs


示例17: ExplicitSaveThrowsWhenSpecifiedAssemblyNotGeneratedStrongName

		public void ExplicitSaveThrowsWhenSpecifiedAssemblyNotGeneratedStrongName()
		{
			var scope = new ModuleScope(true);
			scope.ObtainDynamicModuleWithWeakName();

			Assert.Throws<InvalidOperationException>(() => scope.SaveAssembly(true));
		}
开发者ID:jeremymeng,项目名称:Core,代码行数:7,代码来源:ModuleScopeTestCase.cs


示例18: 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


示例19: InterfaceProxyWithTargetInterfaceTargetContributor

		public InterfaceProxyWithTargetInterfaceTargetContributor(Type proxyTargetType, bool allowChangeTarget,
                                                                  INamingScope namingScope, ModuleScope scope)
			: base(proxyTargetType, allowChangeTarget, namingScope, scope)
		{
		}
开发者ID:BiBongNet,项目名称:JustMockLite,代码行数:5,代码来源:InterfaceProxyWithTargetInterfaceTargetContributor.cs


示例20: SaveReturnsNullWhenNoModuleObtained

		public void SaveReturnsNullWhenNoModuleObtained()
		{
			var scope = new ModuleScope(true);
			Assert.IsNull(scope.SaveAssembly());
		}
开发者ID:jeremymeng,项目名称:Core,代码行数:5,代码来源:ModuleScopeTestCase.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ModuleSetting类代码示例发布时间:2022-05-24
下一篇:
C# ModuleInfo类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap