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


C# TypeBuilder.DefineDefaultConstructor方法代码示例

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


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

示例1: EmitPageConstructors

		/// <summary>
		/// Emits constructors.
		/// </summary>
		private void EmitPageConstructors(TypeBuilder type)
		{
			ConstructorBuilder ctor;
			//      ILGenerator il;
			ConstructorInfo ci;

			//public instance void .ctor()
			//{
			//  ldarg.0
			//  call instance void [PhpNetCore]PHP.Core.PhpPage::.ctor()
			//  ret
			//} 

			ctor = type.DefineDefaultConstructor(MethodAttributes.Public);

			ci = typeof(PhpPage).GetConstructor(
			  BindingFlags.NonPublic | BindingFlags.Instance, // flags: instance family    
			  null,                                           // binder
			  new Type[] { },                                  // params
			  null);                                          // modifiers

			/* obsolete
			//public instance void .ctor(class [PhpNetCore]PHP.Core.ConfigurationRecord)
			//{
			//  ldarg.0
			//  ldarg.1
			//  call instance void [PhpNetCore]PHP.Core.PhpPage::.ctor(class [PhpNetCore]PHP.Core.ConfigurationRecord)
			//  ret
			//} 

			ctor = type.DefineConstructor(
			  MethodAttributes.Public,                         // flags
			  CallingConventions.Standard,                     // calling convention
			  new Type[] {typeof(ConfigurationRecord)});       // params
      
			ci = typeof(PhpPage).GetConstructor(
			  BindingFlags.NonPublic | BindingFlags.Instance,  // flags: instance family    
			  null,                                            // binder
			  new Type[] {typeof(ConfigurationRecord)},        // params
			  null);                                           // modifiers
      
			il = ctor.GetILGenerator();

			il.Emit(OpCodes.Ldarg_0);
			il.Emit(OpCodes.Ldarg_1);
			il.Emit(OpCodes.Call,ci);
			il.Emit(OpCodes.Ret);
			*/
		}
开发者ID:dw4dev,项目名称:Phalanger,代码行数:52,代码来源:SimpleCompiler.cs

示例2: GenerateConstructor

        private static void GenerateConstructor(TypeBuilder dynamicType, string[] properties, List<FieldBuilder> fields)
        {
            const MethodAttributes CtorAttributes = MethodAttributes.RTSpecialName | MethodAttributes.SpecialName | MethodAttributes.HideBySig | MethodAttributes.Public;
            var defaultCtor = dynamicType.DefineDefaultConstructor(CtorAttributes);

            var ctor = dynamicType.DefineConstructor(CtorAttributes, CallingConventions.Standard, fields.Select(x => x.FieldType).ToArray());
            var ctorIl = ctor.GetILGenerator();
            ctorIl.Emit(OpCodes.Ldarg_0);
            ctorIl.Emit(OpCodes.Call, defaultCtor);

            for (var i = 0; i < properties.Length; i++)
            {
                var strParamName = properties[i];
                var field = fields[i];
                var builder3 = ctor.DefineParameter(i + 1, ParameterAttributes.None, strParamName);
                ctorIl.Emit(OpCodes.Ldarg_0);
                ctorIl.Emit(OpCodes.Ldarg, builder3.Position);
                ctorIl.Emit(OpCodes.Stfld, field);
            }

            ctorIl.Emit(OpCodes.Ret);

            AddDebuggerHiddenAttribute(ctor);
        }
开发者ID:devIceMan,项目名称:LambdaBuilder,代码行数:24,代码来源:AnonymousTypeBuilder.cs

示例3: BuildMethod_ctor

 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 private ConstructorBuilder BuildMethod_ctor(TypeBuilder type)
 {
     System.Reflection.MethodAttributes methodAttributes =
           System.Reflection.MethodAttributes.Public
         | System.Reflection.MethodAttributes.HideBySig;
     return type.DefineDefaultConstructor(methodAttributes);
 }
开发者ID:yorkart,项目名称:NDWR,代码行数:12,代码来源:ServiceProxyByteCode.cs

示例4: AddDefaultConstructor

 /// <summary>
 /// add a no arg constructor, which calls the default constructor of the supertype.
 /// </summary>
 public void AddDefaultConstructor(TypeBuilder builder,
                                   MethodAttributes attrs) {
     builder.DefineDefaultConstructor(attrs);
 }
开发者ID:JnS-Software-LLC,项目名称:iiop-net,代码行数:7,代码来源:ILEmitHelper.cs

示例5: DefineDefaultConstructor

		public static ConstructorBuilder DefineDefaultConstructor (TypeBuilder typeBuilder)
		{
			ConstructorBuilder constructorBuilder = typeBuilder.DefineDefaultConstructor (EmitConstants.PUBLIC_CONSTRUCTOR);
			return constructorBuilder;
		}
开发者ID:Monobjc,项目名称:monobjc,代码行数:5,代码来源:EmitTools.cs

示例6: BuildMethod_ctor1

 public void BuildMethod_ctor1(TypeBuilder type)
 {
     // Declaring method builder
     // Method attributes
     System.Reflection.MethodAttributes methodAttributes =
           System.Reflection.MethodAttributes.Public
         | System.Reflection.MethodAttributes.HideBySig;
     ctor = type.DefineDefaultConstructor(methodAttributes);
 }
开发者ID:yorkart,项目名称:NDWR,代码行数:9,代码来源:Class1.cs

示例7: GenerateWrapperConstructor

 private static void GenerateWrapperConstructor(TypeBuilder newType, FieldInfo defaultValue)
 {
     ConstructorBuilder ctor = newType.DefineDefaultConstructor(MethodAttributes.Public);
 }
开发者ID:guidgets,项目名称:DataAccessLayer,代码行数:4,代码来源:ClassWrappers.PropertyWrapperGenerator.cs

示例8: GenerateConstructor

		private static void GenerateConstructor(TypeBuilder type)
		{
			type.DefineDefaultConstructor (MethodAttributes.Public);
		}
开发者ID:991899783,项目名称:DbEntry,代码行数:4,代码来源:MemberHandlerGenerator.cs

示例9: DefineEmptyDefaultConstr

 /// <summary>adds an empty default constructor</summary>
 private void DefineEmptyDefaultConstr(TypeBuilder boxBuilder) {
     boxBuilder.DefineDefaultConstructor(MethodAttributes.Public);
 }
开发者ID:JnS-Software-LLC,项目名称:iiop-net,代码行数:4,代码来源:BoxedValueTypeGenerator.cs


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