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

C# TypeBuilder类代码示例

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

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



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

示例1: Create

 override internal IntPtr Create(TypeBuilder builder)
 {
     if (Type.IsNullable)
         return builder.GetRuntimeTypeHandle(Type.Instantiation[0]).ToIntPtr();
     else
         return builder.GetRuntimeTypeHandle(Type).ToIntPtr();
 }
开发者ID:nattress,项目名称:corert,代码行数:7,代码来源:genericdictionarycell.cs


示例2: MethodBuilder

 /// <summary>
 /// Default ctor
 /// </summary>
 private MethodBuilder(MethodDefinition javaMethod, TypeBuilder declaringTypeBuilder, SignedByteMode signedByteMode)
 {
     this.javaMethod = javaMethod;
     this.declaringTypeBuilder = declaringTypeBuilder;
     this.signedByteMode = signedByteMode;
     this.addJavaPrefix = signedByteMode == SignedByteMode.HasUnsignedPartnerOnlyInReturnType;
 }
开发者ID:Xtremrules,项目名称:dot42,代码行数:10,代码来源:MethodBuilder.cs


示例3: AddAutomagicSerialization

		internal static ConstructorInfo AddAutomagicSerialization(DynamicTypeWrapper wrapper, TypeBuilder typeBuilder)
		{
			ConstructorInfo serializationCtor = null;
			if (wrapper.GetClassLoader().NoAutomagicSerialization)
			{
				// do nothing
			}
			else if ((wrapper.Modifiers & IKVM.Attributes.Modifiers.Enum) != 0)
			{
				MarkSerializable(typeBuilder);
			}
			else if (wrapper.IsSubTypeOf(serializable) && IsSafeForAutomagicSerialization(wrapper))
			{
				if (wrapper.IsSubTypeOf(externalizable))
				{
					MethodWrapper ctor = wrapper.GetMethodWrapper("<init>", "()V", false);
					if (ctor != null && ctor.IsPublic)
					{
						MarkSerializable(typeBuilder);
						ctor.Link();
						serializationCtor = AddConstructor(typeBuilder, ctor, null, true);
						if (!wrapper.BaseTypeWrapper.IsSubTypeOf(serializable))
						{
							AddGetObjectData(typeBuilder);
						}
						if (wrapper.BaseTypeWrapper.GetMethodWrapper("readResolve", "()Ljava.lang.Object;", true) != null)
						{
							RemoveReadResolve(typeBuilder);
						}
					}
				}
				else if (wrapper.BaseTypeWrapper.IsSubTypeOf(serializable))
				{
					ConstructorInfo baseCtor = wrapper.GetBaseSerializationConstructor();
					if (baseCtor != null && (baseCtor.IsFamily || baseCtor.IsFamilyOrAssembly))
					{
						MarkSerializable(typeBuilder);
						serializationCtor = AddConstructor(typeBuilder, null, baseCtor, false);
						AddReadResolve(wrapper, typeBuilder);
					}
				}
				else
				{
					MethodWrapper baseCtor = wrapper.BaseTypeWrapper.GetMethodWrapper("<init>", "()V", false);
					if (baseCtor != null && baseCtor.IsAccessibleFrom(wrapper.BaseTypeWrapper, wrapper, wrapper))
					{
						MarkSerializable(typeBuilder);
						AddGetObjectData(typeBuilder);
#if STATIC_COMPILER
						// because the base type can be a __WorkaroundBaseClass__, we may need to replace the constructor
						baseCtor = ((AotTypeWrapper)wrapper).ReplaceMethodWrapper(baseCtor);
#endif
						baseCtor.Link();
						serializationCtor = AddConstructor(typeBuilder, baseCtor, null, true);
						AddReadResolve(wrapper, typeBuilder);
					}
				}
			}
			return serializationCtor;
		}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:60,代码来源:Serialization.cs


示例4: AddMethodDynamically

	public void AddMethodDynamically (ref TypeBuilder myTypeBld,
			 string mthdName,
			 Type [] mthdParams,
			 Type returnType,
			 string mthdAction)
	{
		MethodBuilder myMthdBld = myTypeBld.DefineMethod (
					mthdName,
					MethodAttributes.Public |
					MethodAttributes.Static,
					returnType,
					mthdParams);

		ILGenerator ILout = myMthdBld.GetILGenerator ();

		int numParams = mthdParams.Length;

		for (byte x = 0; x < numParams; x++)
			ILout.Emit (OpCodes.Ldarg_S, x);

		if (numParams > 1) {
			for (int y = 0; y < (numParams - 1); y++) {
				switch (mthdAction) {
				case "A": ILout.Emit (OpCodes.Add);
					break;
				case "M": ILout.Emit (OpCodes.Mul);
					break;
				default: ILout.Emit (OpCodes.Add);
					break;
				}
			}
		}
		ILout.Emit (OpCodes.Ret);
	}
开发者ID:mono,项目名称:gert,代码行数:34,代码来源:test.cs


示例5: GetRuntimeTypeHandleWithNullableTransform

 // Helper method for nullable transform. Ideally, we would do the nullable transform upfront before
 // the types is build. Unfortunately, there does not seem to be easy way to test for Nullable<> type definition
 // without introducing type builder recursion
 private static RuntimeTypeHandle GetRuntimeTypeHandleWithNullableTransform(TypeBuilder builder, TypeDesc type)
 {
     RuntimeTypeHandle th = builder.GetRuntimeTypeHandle(type);
     if (RuntimeAugments.IsNullable(th))
         th = builder.GetRuntimeTypeHandle(((DefType)type).Instantiation[0]);
     return th;
 }
开发者ID:nattress,项目名称:corert,代码行数:10,代码来源:genericdictionarycell.cs


示例6: NestedTypeBuilder

 /// <summary>
 /// Default ctor
 /// </summary>
 protected NestedTypeBuilder(TypeBuilder parent, string parentFullName, ClassFile cf, InnerClass inner)
 {
     this.parent = parent;
     this.parentFullName = parentFullName;
     this.cf = cf;
     this.inner = inner;
 }
开发者ID:rfcclub,项目名称:dot42,代码行数:10,代码来源:NestedTypeBuilder.cs


示例7: MethodBuilder

 /// <summary>
 /// Default ctor
 /// </summary>
 private MethodBuilder(MethodDefinition javaMethod, TypeBuilder declaringTypeBuilder, bool convertSignedBytes, bool addJavaPrefix)
 {
     this.javaMethod = javaMethod;
     this.declaringTypeBuilder = declaringTypeBuilder;
     this.convertSignedBytes = convertSignedBytes;
     this.addJavaPrefix = addJavaPrefix;
 }
开发者ID:rfcclub,项目名称:dot42,代码行数:10,代码来源:MethodBuilder.cs


示例8: ImplementMembersForm

        public ImplementMembersForm(NemerleSource source, TypeBuilder ty, IEnumerable<IGrouping<FixedType.Class, IMember>> unimplementedMembers)
        {
            _source               = source;
            _ty                   = ty;
            _unimplementedMembers = unimplementedMembers;

            InitializeComponent();

            #region Init events hendlers

            _grid.CellPainting += CellPainting;
            _grid.CellValueChanged += CellValueChanged;
            _grid.CellValidating += CellValidating;
            _grid.CurrentCellDirtyStateChanged += CurrentCellDirtyStateChanged;

            #endregion
            #region Init ImageList

            imageList1.Images.AddStrip(Resources.SO_TreeViewIcons);
            _imageSize = imageList1.ImageSize.Width;
            Debug.Assert(imageList1.ImageSize.Width == imageList1.ImageSize.Height);

            #endregion

            if (_unimplementedMembers == null)
                return;

            FillTable(MakeTypeMembersMap());
        }
开发者ID:vestild,项目名称:nemerle,代码行数:29,代码来源:ImplementMembersForm.cs


示例9: Prepare

            override internal void Prepare(TypeBuilder builder)
            {
                if (Type.IsCanonicalSubtype(CanonicalFormKind.Any))
                    Environment.FailFast("Canonical types do not have EETypes");

                builder.RegisterForPreparation(Type);
            }
开发者ID:nattress,项目名称:corert,代码行数:7,代码来源:genericdictionarycell.cs


示例10: CreateProperty

            private static void CreateProperty(TypeBuilder tb, string propertyName, Type propertyType)
            {
                FieldBuilder fieldBuilder = tb.DefineField("_" + propertyName, propertyType, FieldAttributes.Private);

                PropertyBuilder propertyBuilder = tb.DefineProperty(propertyName, PropertyAttributes.HasDefault, propertyType, null);
                MethodBuilder getPropMthdBldr = tb.DefineMethod("get_" + propertyName, MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.HideBySig, propertyType, Type.EmptyTypes);
                ILGenerator getIl = getPropMthdBldr.GetILGenerator();

                getIl.Emit(OpCodes.Ldarg_0);
                getIl.Emit(OpCodes.Ldfld, fieldBuilder);
                getIl.Emit(OpCodes.Ret);

                MethodBuilder setPropMthdBldr =
                tb.DefineMethod("set_" + propertyName,
                  MethodAttributes.Public |
                  MethodAttributes.SpecialName |
                  MethodAttributes.HideBySig,
                  null, new[] { propertyType });

                ILGenerator setIl = setPropMthdBldr.GetILGenerator();
                Label modifyProperty = setIl.DefineLabel();
                Label exitSet = setIl.DefineLabel();

                setIl.MarkLabel(modifyProperty);
                setIl.Emit(OpCodes.Ldarg_0);
                setIl.Emit(OpCodes.Ldarg_1);
                setIl.Emit(OpCodes.Stfld, fieldBuilder);

                setIl.Emit(OpCodes.Nop);
                setIl.MarkLabel(exitSet);
                setIl.Emit(OpCodes.Ret);

                propertyBuilder.SetGetMethod(getPropMthdBldr);
                propertyBuilder.SetSetMethod(setPropMthdBldr);
            }
开发者ID:siarheimilkevich,项目名称:VSSync,代码行数:35,代码来源:TypeBuilder.cs


示例11: Create

 internal static IEnumerable<NestedTypeBuilder> Create(TypeBuilder parent, string parentFullName, ClassFile cf, InnerClass inner)
 {
     if (cf.IsInterface && cf.Fields.Any())
     {
         yield return new NestedInterfaceConstantsTypeBuilder(parent, parentFullName, cf, inner);
     }
     yield return new NestedTypeBuilder(parent, parentFullName, cf, inner);
 }
开发者ID:rfcclub,项目名称:dot42,代码行数:8,代码来源:NestedTypeBuilder.cs


示例12: FieldBuilder

 /// <summary>
 /// Default ctor
 /// </summary>
 public FieldBuilder(FieldDefinition javaField, TypeBuilder declaringTypeBuilder)
 {
     if (javaField == null)
         throw new ArgumentNullException("javaField");
     if (declaringTypeBuilder == null)
         throw new ArgumentNullException("declaringTypeBuilder");
     this.javaField = javaField;
     this.declaringTypeBuilder = declaringTypeBuilder;
 }
开发者ID:Xtremrules,项目名称:dot42,代码行数:12,代码来源:FieldBuilder.cs


示例13: Finish

        public unsafe void Finish(TypeBuilder typeBuilder)
        {
            Debug.Assert(_cells.Length == 0 || _addressOfFirstCellSlot != IntPtr.Zero);

            IntPtr* realCells = (IntPtr*)_addressOfFirstCellSlot;
            for (int i = 0; i < _cells.Length; i++)
            {
                realCells[i] = _cells[i].Create(typeBuilder);
            }
        }
开发者ID:nattress,项目名称:corert,代码行数:10,代码来源:GenericDictionary.cs


示例14: BuildEntitySets

        private void BuildEntitySets(EdmEntityContainer container, IEnumerable<EntityElement> rootElements, TypeBuilder typeBuilder)
        {
            foreach (var rootEntity in rootElements)
            {
                var entitySetName = rootEntity.EntitySetName ?? rootEntity.ResolveName();
                var schemaType = typeBuilder.BuildSchemaType(rootEntity);

                container.AddEntitySet(entitySetName, (IEdmEntityType)schemaType);
            }
        }
开发者ID:2gis,项目名称:nuclear-river,代码行数:10,代码来源:EdmModelBuilder.cs


示例15: FieldBuilder

 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="TypeBuilder">Type builder</param>
 /// <param name="Name">Name of the method</param>
 /// <param name="Attributes">Attributes for the field (public, private, etc.)</param>
 /// <param name="FieldType">Type for the field</param>
 public FieldBuilder(TypeBuilder TypeBuilder, string Name, Type FieldType, FieldAttributes Attributes)
     : base()
 {
     Contract.Requires<ArgumentNullException>(TypeBuilder!=null,"TypeBuilder");
     Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(Name),"Name");
     this.Name = Name;
     this.Type = TypeBuilder;
     this.DataType = FieldType;
     this.Attributes = Attributes;
     Builder = Type.Builder.DefineField(Name, FieldType, Attributes);
 }
开发者ID:kaytie,项目名称:Craig-s-Utility-Library,代码行数:18,代码来源:FieldBuilder.cs


示例16: FieldBuilder

 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="typeBuilder">Type builder</param>
 /// <param name="name">Name of the method</param>
 /// <param name="attributes">Attributes for the field (public, private, etc.)</param>
 /// <param name="fieldType">Type for the field</param>
 public FieldBuilder(TypeBuilder typeBuilder, string name, Type fieldType, FieldAttributes attributes)
 {
     if (typeBuilder == null)
         throw new ArgumentNullException("typeBuilder");
     if (string.IsNullOrEmpty(name))
         throw new ArgumentNullException("name");
     Name = name;
     Type = typeBuilder;
     DataType = fieldType;
     Attributes = attributes;
     Builder = Type.Builder.DefineField(name, fieldType, attributes);
 }
开发者ID:OxPatient,项目名称:Rule-Engine,代码行数:19,代码来源:FieldBuilder.cs


示例17: ImplementMethod

        private MethodBuilder ImplementMethod(TypeBuilder type, string methodName, MethodAttributes methodAttr, Type returnType, Type[] paramTypes, FieldBuilder field)
        {
            MethodBuilder method = type.DefineMethod(methodName, methodAttr, returnType, paramTypes);

            ILGenerator methodILGenerator = method.GetILGenerator();
            methodILGenerator.Emit(OpCodes.Ldarg_0);
            methodILGenerator.Emit(OpCodes.Ldarg_1);
            methodILGenerator.Emit(OpCodes.Stfld, field);
            methodILGenerator.Emit(OpCodes.Ret);

            return method;
        }
开发者ID:ESgarbi,项目名称:corefx,代码行数:12,代码来源:PropertyBuilderSetSetMethod.cs


示例18: EmitCtor

	static void EmitCtor (TypeBuilder genericFoo) {
		ConstructorBuilder mb = genericFoo.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, null);
		ILGenerator il = mb.GetILGenerator ();
		for (int i = 0; i < 20; ++i)
				il.Emit (OpCodes.Nop);

		il.Emit (OpCodes.Ldarg_0);
		il.Emit (OpCodes.Call, typeof (object).GetConstructors()[0]);
		il.Emit (OpCodes.Ret);

		ctor = mb;
	}
开发者ID:Zman0169,项目名称:mono,代码行数:12,代码来源:bug-389886-2.cs


示例19: NotCreateOtherElements

        public void NotCreateOtherElements()
        {
            CompilerContext cc = new CompilerContext();
            GenericTypeBuilder gtb = new GenericTypeBuilder();
            TypeBuilder tb = new TypeBuilder();
            Testdata.ClassA classa = new Testdata.ClassA();
            System.Reflection.ReflectionClass rc = new System.Reflection.ReflectionClass();

            Assert.IsNull(TreeElementCreator.CreateFromObject("cc", cc));
            Assert.IsNull(TreeElementCreator.CreateFromObject("gtb", gtb));
            Assert.IsNull(TreeElementCreator.CreateFromObject("tb", tb));
            Assert.IsNull(TreeElementCreator.CreateFromObject("rc", rc));
        }
开发者ID:ifanatic,项目名称:CSharpParseTree,代码行数:13,代码来源:TreeElementCreatorTest.cs


示例20: FieldBuilder

 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="TypeBuilder">Type builder</param>
 /// <param name="Name">Name of the method</param>
 /// <param name="Attributes">Attributes for the field (public, private, etc.)</param>
 /// <param name="FieldType">Type for the field</param>
 public FieldBuilder(TypeBuilder TypeBuilder, string Name, Type FieldType, FieldAttributes Attributes)
     : base()
 {
     if (TypeBuilder == null)
         throw new ArgumentNullException("TypeBuilder");
     if (string.IsNullOrEmpty(Name))
         throw new ArgumentNullException("Name");
     this.Name = Name;
     this.Type = TypeBuilder;
     this.DataType = FieldType;
     this.Attributes = Attributes;
     Builder = Type.Builder.DefineField(Name, FieldType, Attributes);
 }
开发者ID:jpsullivan,项目名称:Craig-s-Utility-Library,代码行数:20,代码来源:FieldBuilder.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# TypeCode类代码示例发布时间:2022-05-24
下一篇:
C# TypeBase类代码示例发布时间: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