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


C# AssemblyBuilderAccess类代码示例

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


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

示例1: DefineDynamicAssembly

 internal AssemblyBuilder DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access)
 {
     var realAba = EmitWrapper.Mscorlib.GetType("System.Reflection.Emit.AssemblyBuilderAccess");
     var result = this.Invoke("DefineDynamicAssembly", new Type[] { typeof(AssemblyName), 
         realAba }, name, access);
     return new AssemblyBuilder(result);
 }
开发者ID:rajgit31,项目名称:MetroUnitTestsDemoApp,代码行数:7,代码来源:AppDomain.cs

示例2: AssemblyBuilder

	// Constructor.  Called from AppDomain.DefineDynamicAssembly.
	internal AssemblyBuilder(AssemblyName name, AssemblyBuilderAccess access,
							 String directory, bool isSynchronized)
			{
				this.access = access;
				this.directory = (directory == null) ? "." : directory;
				this.isSynchronized = isSynchronized;
				this.saved = false;
				this.entryPoint = null;
				this.detachList = new ArrayList();
				fileKind = PEFileKinds.Dll;
				Version version = name.Version;
				lock(typeof(AssemblyBuilder))
				{
					if(version != null)
					{
						this.privateData = ClrAssemblyCreate
							(name.Name, version.Major, version.Minor,
							 version.Build, version.Revision,
							 access, out writer);
					}
					else
					{
						this.privateData = ClrAssemblyCreate
							(name.Name, 0, 0, 0, 0, access, out writer);
					}
				}
				if(this.privateData == IntPtr.Zero)
				{
					// The runtime engine disallowed dynamic assemblies.
					throw new SecurityException
						(_("Emit_NoDynamicAssemblies"));
				}
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:34,代码来源:AssemblyBuilder.cs

示例3: CreateDynamicAssembly

 private AssemblyBuilder CreateDynamicAssembly(string name, AssemblyBuilderAccess access)
 {
     AssemblyName myAsmName = new AssemblyName();
     myAsmName.Name = name;
     AssemblyBuilder myAsmBuilder = AssemblyBuilder.DefineDynamicAssembly(myAsmName, access);
     return myAsmBuilder;
 }
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:7,代码来源:LabelGetHashCode.cs

示例4: GetCustomType

 private TypeBuilder GetCustomType(string name, AssemblyBuilderAccess access)
 {
     AssemblyName myAsmName = new AssemblyName();
     myAsmName.Name = name;
     AssemblyBuilder myAsmBuilder = AssemblyBuilder.DefineDynamicAssembly(myAsmName, access);
     ModuleBuilder moduleBuilder = TestLibrary.Utilities.GetModuleBuilder(myAsmBuilder, TestModuleName);
     return moduleBuilder.DefineType(TestTypeName);
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:8,代码来源:LocalBuilderLocalIndex.cs

示例5: SetUp

		protected void SetUp (AssemblyBuilderAccess mode)
		{
			AssemblyName assemblyName = new AssemblyName ();
			assemblyName.Name = ASSEMBLY_NAME;

			assembly =
				Thread.GetDomain ().DefineDynamicAssembly (
					assemblyName, mode, Path.GetTempPath ());

			module = assembly.DefineDynamicModule ("module1");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:11,代码来源:GenericTypeParameterBuilderTest.cs

示例6: SetUp

		void SetUp (AssemblyBuilderAccess access)
		{
			AssemblyName assemblyName = new AssemblyName ();
			assemblyName.Name = ASSEMBLY_NAME;

			assembly =
				Thread.GetDomain ().DefineDynamicAssembly (
					assemblyName, access, Path.GetTempPath ());

			module = assembly.DefineDynamicModule ("module1");
			typeCount = 0;
		}
开发者ID:kumpera,项目名称:mono,代码行数:12,代码来源:MonoGenericClassTest.cs

示例7: GetAssemblyBuilder

 public AssemblyBuilder GetAssemblyBuilder()
 {
     if (_assemblyBuilder == null)
     {
         AssemblyBuilderAccess = AssemblyBuilderAccess.RunAndCollect;
         _assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(
                 new AssemblyName(_assemblyName),
                 AssemblyBuilderAccess
             );
     }
     return _assemblyBuilder;
 }
开发者ID:kazuk,项目名称:ProjectOosaki,代码行数:12,代码来源:AssembleContext.cs

示例8: GetRefEmitAssembly

        public static Assembly GetRefEmitAssembly(string assemblyNameStr, AssemblyBuilderAccess builderType)
        {
            var assemblyName = new AssemblyName(assemblyNameStr);
            
            AssemblyBuilder builder = AssemblyBuilder.DefineDynamicAssembly(assemblyName, builderType);
            ModuleBuilder moduleBuilder = builder.DefineDynamicModule("RefEmitModule");

            TypeBuilder typeBuilder = moduleBuilder.DefineType("RefEmitTestType", TypeAttributes.Public);
            
            // Define "Assembly LoadStaticAssembly(string)" method that will load a static assembly
            MethodBuilder methodBuilder = typeBuilder.DefineMethod("LoadStaticAssembly", MethodAttributes.Public|MethodAttributes.Static, typeof(Assembly), new Type[]{typeof(string)});
            ILGenerator ilGenerator = methodBuilder.GetILGenerator();

            // Generate the following code:
            //
            // AssemblyName name = new AssemblyName(name); // name is the argument passed to LoadStaticAssembly
            // Assembly.Load(name);

            // Declare the locals
            LocalBuilder localAssemblyName = ilGenerator.DeclareLocal(typeof(AssemblyName));
            LocalBuilder localAssembly = ilGenerator.DeclareLocal(typeof(Assembly));

            // Fetch reference to AssemblyName ctor we want to invoke
            ConstructorInfo ctorAssemblyName = TypeExtensions.GetConstructor(typeof(System.Reflection.AssemblyName), new Type[] {typeof(string)});

            // Load incoming assemblyname string
            ilGenerator.Emit(OpCodes.Ldarg_0);  

            // Create new object of the type AssemblyName
            ilGenerator.Emit(OpCodes.Newobj, ctorAssemblyName);

            // "this" for assemblyname instance is already at the top of evaluation stack.
            //
            // Invoke Assembly.Load
            MethodInfo miAssemblyLoad = TypeExtensions.GetMethod(typeof(System.Reflection.Assembly), "Load", new Type[] {typeof(System.Reflection.AssemblyName)});
            ilGenerator.Emit(OpCodes.Call, miAssemblyLoad);

            // Return the reference to the loaded assembly
            ilGenerator.Emit(OpCodes.Ret);

            // Generate the type
            typeBuilder.CreateTypeInfo().AsType();

            // Return the generated assembly
            return builder;
        }
开发者ID:Corillian,项目名称:corefx,代码行数:46,代码来源:TestClass.cs

示例9: DynamicAssembly

        public DynamicAssembly (String assemblyName, String moduleName, AssemblyBuilderAccess access = AssemblyBuilderAccess.RunAndSave)
        {
            this.assemblyName = assemblyName;
            this.moduleName = moduleName;

            // Define dynamic assembly
            AssemblyName name = new AssemblyName { Name = this.assemblyName, Version = Assembly.GetExecutingAssembly().GetName().Version };
            this.assembly = AppDomain.CurrentDomain.DefineDynamicAssembly (name, access);

            // Define dynamic module
            if (access == AssemblyBuilderAccess.RunAndSave || access == AssemblyBuilderAccess.Save) {
                // Persistent
                this.module = this.assembly.DefineDynamicModule (this.moduleName, this.assemblyName + ".dll");
            } else {
                // Transient
                this.module = this.assembly.DefineDynamicModule (this.moduleName);
            }
        }
开发者ID:Monobjc,项目名称:monobjc,代码行数:18,代码来源:DynamicAssembly.cs

示例10: ProxyModule

 public ProxyModule(string assemblyName, AssemblyBuilderAccess access)
 {
     _assemblyName = assemblyName;
     _assemblyNameWithExt = _assemblyName + ".dll";
     switch (access)
     {
         case AssemblyBuilderAccess.Run:
             break;
         case AssemblyBuilderAccess.RunAndSave:
             break;
         case AssemblyBuilderAccess.RunAndCollect:
             break;
         default:
             throw new ArgumentOutOfRangeException("access", "Run, RunAndSave, or RunAndCollect are the only permitted options");
     }
     _access = access;
     _factories = new object[_factoryTypeCount];
 }
开发者ID:davidvmckay,项目名称:ProxyFoo,代码行数:18,代码来源:ProxyModule.cs

示例11: ProxyContext

        public ProxyContext(AssemblyBuilderAccess access, bool verify, bool generateDebugging)
            : this()
        {
            if ((access & AssemblyBuilderAccess.Run) != AssemblyBuilderAccess.Run)
            {
                throw new ArgumentException(
                     "Invalid access value - the assembly must have Run access.", "access");
            }

            if (verify && ((access & AssemblyBuilderAccess.Save) != AssemblyBuilderAccess.Save))
            {
                throw new ArgumentException("Verification cannot be done on a transient assembly.",
                     "verify");
            }

            // TODO - I'm not sure if debugging can be done on transient assemblies...
            this.Access = access;
            this.Verify = verify;
            this.GenerateDebugging = generateDebugging;
        }
开发者ID:JasonBock,项目名称:DynamicProxies,代码行数:20,代码来源:ProxyContext.cs

示例12: AssemblyBuilderData

        internal AssemblyBuilderData(
            InternalAssemblyBuilder assembly, 
            String                  strAssemblyName, 
            AssemblyBuilderAccess   access,
            String                  dir)
        {
            m_assembly = assembly;
            m_strAssemblyName = strAssemblyName;
            m_access = access;
            m_moduleBuilderList = new List<ModuleBuilder>();
            m_resWriterList = new List<ResWriterData>();

            //Init to null/0 done for you by the CLR.  FXCop has spoken

            if (dir == null && access != AssemblyBuilderAccess.Run)
                m_strDir = Environment.CurrentDirectory;
            else
                m_strDir = dir;

            m_peFileKind = PEFileKinds.Dll;
         }
开发者ID:kouvel,项目名称:coreclr,代码行数:21,代码来源:AssemblyBuilderData.cs

示例13: SetUp

		void SetUp (AssemblyBuilderAccess access)
		{
			AssemblyName assemblyName = new AssemblyName ();
			assemblyName.Name = ASSEMBLY_NAME;

			assembly = AppDomain.CurrentDomain.DefineDynamicAssembly (
				assemblyName, access,
				Path.GetTempPath ());

			module = assembly.DefineDynamicModule ("module1");

			tb = module.DefineType ("Bar");
			GenericTypeParameterBuilder [] typeParams = tb.DefineGenericParameters ("T");

			cb = tb.DefineConstructor (MethodAttributes.Public,
				CallingConventions.Standard,
				new Type [] { typeof (string), typeof (int) });
			ILGenerator ig = cb.GetILGenerator ();
			ig.Emit (OpCodes.Ret);

			typeBarOfInt32 = tb.MakeGenericType (typeof (int));
			ci = TypeBuilder.GetConstructor (typeBarOfInt32, cb);
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:23,代码来源:ConstructorOnTypeBuilderInstTest.cs

示例14: AssemblyBuilderData

        internal AssemblyBuilderData(
            Assembly            assembly, 
            String              strAssemblyName, 
            AssemblyBuilderAccess access,
            String              dir)
        {
            m_assembly = assembly;
            m_strAssemblyName = strAssemblyName;
            m_access = access;
            m_moduleBuilderList = new ArrayList();
            m_resWriterList = new ArrayList();
            m_publicComTypeList = null;
            m_CABuilders = null;
            m_CABytes = null;
            m_CACons = null;
            m_iPublicComTypeCount = 0;    
            m_iCABuilder = 0;
            m_iCAs = 0;
            m_entryPointModule = null;
            m_isSaved = false;
            if (dir == null && access != AssemblyBuilderAccess.Run)
                m_strDir = Environment.CurrentDirectory;
            else
                m_strDir = dir;
            m_RequiredPset = null;
            m_OptionalPset = null;
            m_RefusedPset = null;
            m_isSynchronized = false;

            m_InMemoryAssemblyModule = null;
            m_OnDiskAssemblyModule = null;
            m_peFileKind = PEFileKinds.Dll;

            m_entryPointMethod = null;
            m_ISymWrapperAssembly = null;
         }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:36,代码来源:assemblybuilderdata.cs

示例15: AssemblyBuilder

		internal AssemblyBuilder (AssemblyName n, string directory, AssemblyBuilderAccess access, bool corlib_internal)
		{
			/* This is obsolete now, as mcs doesn't use SRE any more */
			if ((access & COMPILER_ACCESS) != 0)
				throw new NotImplementedException ("COMPILER_ACCESS is no longer supperted, use a newer mcs.");

			if (!Enum.IsDefined (typeof (AssemblyBuilderAccess), access))
				throw new ArgumentException (string.Format (CultureInfo.InvariantCulture,
					"Argument value {0} is not valid.", (int) access),
					"access");

			name = n.Name;
			this.access = (uint)access;
			flags = (uint) n.Flags;

			// don't call GetCurrentDirectory for Run-only builders (CAS may not like that)
			if (IsSave && (directory == null || directory.Length == 0)) {
				dir = Directory.GetCurrentDirectory ();
			} else {
				dir = directory;
			}

			/* Set defaults from n */
			if (n.CultureInfo != null) {
				culture = n.CultureInfo.Name;
				versioninfo_culture = n.CultureInfo.Name;
			}
			Version v = n.Version;
			if (v != null) {
				version = v.ToString ();
			}

			if (n.KeyPair != null) {
				// full keypair is available (for signing)
				sn = n.KeyPair.StrongName ();
			} else {
				// public key is available (for delay-signing)
				byte[] pk = n.GetPublicKey ();
				if ((pk != null) && (pk.Length > 0)) {
					sn = new Mono.Security.StrongName (pk);
				}
			}

			if (sn != null)
				flags |= (uint) AssemblyNameFlags.PublicKey;

			this.corlib_internal = corlib_internal;
			if (sn != null) {
				this.pktoken = new byte[sn.PublicKeyToken.Length * 2];
				int pkti = 0;
				foreach (byte pkb in sn.PublicKeyToken) {
					string part = pkb.ToString("x2");
					this.pktoken[pkti++] = (byte)part[0];
					this.pktoken[pkti++] = (byte)part[1];
				}
			}

			basic_init (this);
		}
开发者ID:sjlangley,项目名称:mono,代码行数:59,代码来源:AssemblyBuilder.cs


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