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

C# Emit.GenericTypeParameterBuilder类代码示例

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

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



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

示例1: DefineGenericTypeParameter

 protected virtual unsafe void DefineGenericTypeParameter(TypeBuilder typeBuilder, GenericTypeParameterBuilder paramBuilder, BCSYM_GenericParam* pParam)
 {
     paramBuilder.SetGenericParameterAttributes(GetGenericParameterAttributes(pParam));
     List<Type> list = new List<Type>();
     for (BCSYM_GenericConstraint* constraintPtr = *((BCSYM_GenericConstraint**) (pParam + 0x54)); constraintPtr != null; constraintPtr = *((BCSYM_GenericConstraint**) (constraintPtr + 8)))
     {
         if (((byte) (*(((byte*) constraintPtr)) == 0x26)) != 0)
         {
             BCSYM* pSymbol = BCSYM.DigThroughNamedType(*((BCSYM* modopt(IsConst) modopt(IsConst)*) (constraintPtr + 12)));
             Type item = this.GetType(typeBuilder, pSymbol);
             if (BCSYM.IsInterface(pSymbol))
             {
                 list.Add(item);
             }
             else
             {
                 paramBuilder.SetBaseTypeConstraint(item);
             }
         }
     }
     if (list.Count > 0)
     {
         paramBuilder.SetInterfaceConstraints(list.ToArray());
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:25,代码来源:TypeEmitter.cs


示例2: HandlerClassBuildingContext

 public HandlerClassBuildingContext(IReadOnlyList<ServiceDescription> serviceDescriptionChain, MethodDescription methodDescription, 
     TypeBuilder builder, GenericTypeParameterBuilder[] genericTypeParameterBuilders, HandlerClassFieldCache fields)
 {
     ServiceDescriptionChain = serviceDescriptionChain;
     MethodDescription = methodDescription;
     Builder = builder;
     GenericTypeParameterBuilders = genericTypeParameterBuilders;
     Fields = fields;
 }
开发者ID:yonglehou,项目名称:SharpRPC,代码行数:9,代码来源:HandlerClassBuildingContext.cs


示例3: RegisterBuilder

 internal void RegisterBuilder(GenericTypeParameterBuilder builder)
 {
     if (Builder != null)
     {
         throw new InvalidOperationException();
     }
     Builder = builder;
     Info = Builder;
 }
开发者ID:B-head,项目名称:Dreit-prototype,代码行数:9,代码来源:GenericParameterStructure.cs


示例4: StubInfo

		public StubInfo(MethodBase methodBase, ParameterInfo[] parameters,
			GenericTypeParameterBuilder[] typeParameters, Type returnType)
		{
			Debug.Assert(methodBase is MethodBuilder || methodBase is ConstructorBuilder);

			this.methodBase = methodBase;
			this.Parameters = parameters;
			this.TypeParameters = typeParameters;
			this.ReturnType = returnType;
		}
开发者ID:dw4dev,项目名称:Phalanger,代码行数:10,代码来源:ClrStubBuilder.cs


示例5: BindDelegateExpression

		public BindDelegateExpression(Type @delegate, Expression owner, MethodInfo methodToBindTo, GenericTypeParameterBuilder[] genericTypeParams)
		{
			delegateCtor = @delegate.GetConstructors()[0];
			this.methodToBindTo = methodToBindTo;
			if(@delegate.IsGenericTypeDefinition)
			{
				var closedDelegate = @delegate.MakeGenericType(genericTypeParams);
				delegateCtor = TypeBuilder.GetConstructor(closedDelegate, delegateCtor);
				this.methodToBindTo = methodToBindTo.MakeGenericMethod(genericTypeParams);
			}
			this.owner = owner;
		}
开发者ID:vbedegi,项目名称:Castle.Core,代码行数:12,代码来源:BindDelegateExpression.cs


示例6: FinishDefinition

 internal void FinishDefinition(GenericTypeParameterBuilder arg)
 {
     Contracts.Require.IsNotNull("arg", arg);
     arg.SetGenericParameterAttributes(Attributes);
     if (_baseTypeConstraint != null)
     {
         arg.SetBaseTypeConstraint(_baseTypeConstraint.Target);
     }
     if (_interfaceConstraints.Count > 0)
     {
         arg.SetInterfaceConstraints((from i in _interfaceConstraints
                                                                  select i.Target).ToArray());
     }
 }
开发者ID:rreynolds-yp,项目名称:csharp-swift-consoleclient,代码行数:14,代码来源:EmittedGenericArgument.cs


示例7: RegisterBuilders

 public static void RegisterBuilders(this IReadOnlyList<GenericParameterStructure> gnr, GenericTypeParameterBuilder[] builders)
 {
     for (var i = 0; i < gnr.Count; ++i)
     {
         gnr[i].RegisterBuilder(builders[i]);
     }
 }
开发者ID:B-head,项目名称:Dreit-prototype,代码行数:7,代码来源:TranslateUtility.cs


示例8: AdjustGenericConstraints

 private static Type[] AdjustGenericConstraints(MethodInfo methodToCopyGenericsFrom,
                                                GenericTypeParameterBuilder[] newGenericParameters,
                                                Type[] originalGenericArguments,
                                                Type[] constraints)
 {
     for (var i = 0; i < constraints.Length; i++)
     {
         constraints[i] = AdjustConstraintToNewGenericParameters(constraints[i],
                                                                 methodToCopyGenericsFrom,
                                                                 originalGenericArguments,
                                                                 newGenericParameters);
     }
     return constraints;
 }
开发者ID:JohnsonYuan,项目名称:n2cms,代码行数:14,代码来源:GenericUtil.cs


示例9: Define

		//
		// This is the first method which is called during the resolving
		// process; we're called immediately after creating the type parameters
		// with SRE (by calling `DefineGenericParameters()' on the TypeBuilder /
		// MethodBuilder).
		//
		public void Define (GenericTypeParameterBuilder type, TypeSpec declaringType)
		{
			if (builder != null)
				throw new InternalErrorException ();

			this.builder = type;
			spec.DeclaringType = declaringType;
			spec.SetMetaInfo (type);
		}
开发者ID:ikvm,项目名称:mono,代码行数:15,代码来源:generic.cs


示例10: BuildProperties

    private static void BuildProperties(DynamicTypeInfo info, TypeBuilder typBuilder, 
      List<FieldBuilder> fieldBuilders, GenericTypeParameterBuilder[] parameterBuilders) {
      for (int i = 0; i < info.PropertyNames.Count; i++) {
        //var propBuilder = typBuilder.DefineProperty(
        //  info.PropertyNames[i], PropertyAttributes.None, parameterBuilders[i], Type.EmptyTypes);
        var propBuilder = typBuilder.DefineProperty(
          info.PropertyNames[i], PropertyAttributes.HasDefault, parameterBuilders[i], Type.EmptyTypes);

        // Build Get prop
        var getMethBuilder = typBuilder.DefineMethod(
          "get_" + info.PropertyNames[i], MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.HideBySig,
          parameterBuilders[i], Type.EmptyTypes);
        var generator = getMethBuilder.GetILGenerator();

        generator.Emit(OpCodes.Ldarg_0); // load 'this'
        generator.Emit(OpCodes.Ldfld, fieldBuilders[i]); // load the field
        generator.Emit(OpCodes.Ret);
        propBuilder.SetGetMethod(getMethBuilder);

        // Build Set prop
        var setMethBuilder = typBuilder.DefineMethod(
          "set_" + info.PropertyNames[i], MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.HideBySig, 
          typeof(void), new Type[] { fieldBuilders[i].FieldType });
        generator = setMethBuilder.GetILGenerator();

        generator.Emit(OpCodes.Ldarg_0); // load 'this'
        generator.Emit(OpCodes.Ldarg_1); // load value
        generator.Emit(OpCodes.Stfld, fieldBuilders[i]);
        generator.Emit(OpCodes.Ret);
        propBuilder.SetSetMethod(setMethBuilder);
      }
    }
开发者ID:Javvar,项目名称:Breeze,代码行数:32,代码来源:DynamicGenericTypeBuilder.cs


示例11: DefineGenericParameters

        public GenericTypeParameterBuilder[] DefineGenericParameters(params string[] names)
        {
            if (names == null)
                throw new ArgumentNullException("names");

            if (names.Length == 0)
                throw new ArgumentException();
            Contract.EndContractBlock();
           
            for (int i = 0; i < names.Length; i ++)
                if (names[i] == null)
                    throw new ArgumentNullException("names");

            if (m_inst != null)
                throw new InvalidOperationException();

            m_inst = new GenericTypeParameterBuilder[names.Length];
            for(int i = 0; i < names.Length; i ++)
                m_inst[i] = new GenericTypeParameterBuilder(new TypeBuilder(names[i], i, this));

            return m_inst;
        }
开发者ID:uQr,项目名称:referencesource,代码行数:22,代码来源:typebuilder.cs


示例12: CopyNonInheritableAttributes

		private static void CopyNonInheritableAttributes(GenericTypeParameterBuilder newGenericParameter,
		                                                 Type originalGenericArgument)
		{
			foreach (var attribute in originalGenericArgument.GetTypeInfo().GetNonInheritableAttributes())
			{
				newGenericParameter.SetCustomAttribute(attribute);
			}
		}
开发者ID:jeremymeng,项目名称:Core,代码行数:8,代码来源:GenericUtil.cs


示例13: AdjustConstraintToNewGenericParameters

		private static Type AdjustConstraintToNewGenericParameters(
			Type constraint, MethodInfo methodToCopyGenericsFrom, Type[] originalGenericParameters,
			GenericTypeParameterBuilder[] newGenericParameters)
		{
			if (constraint.GetTypeInfo().IsGenericType)
			{
				var genericArgumentsOfConstraint = constraint.GetGenericArguments();

				for (var i = 0; i < genericArgumentsOfConstraint.Length; ++i)
				{
					genericArgumentsOfConstraint[i] =
						AdjustConstraintToNewGenericParameters(genericArgumentsOfConstraint[i], methodToCopyGenericsFrom,
						                                       originalGenericParameters, newGenericParameters);
				}
				return constraint.GetGenericTypeDefinition().MakeGenericType(genericArgumentsOfConstraint);
			}
			else if (constraint.GetTypeInfo().IsGenericParameter)
			{
				// Determine the source of the parameter
				if (constraint.GetTypeInfo().DeclaringMethod != null)
				{
					// constraint comes from the method
					var index = Array.IndexOf(originalGenericParameters, constraint);
					Trace.Assert(index != -1,
					             "When a generic method parameter has a constraint on another method parameter, both parameters must be declared on the same method.");
					return newGenericParameters[index].AsType();
				}
				else // parameter from surrounding type
				{
					Trace.Assert(constraint.DeclaringType.GetTypeInfo().IsGenericTypeDefinition);
					Trace.Assert(methodToCopyGenericsFrom.DeclaringType.GetTypeInfo().IsGenericType
					             && constraint.DeclaringType == methodToCopyGenericsFrom.DeclaringType.GetGenericTypeDefinition(),
					             "When a generic method parameter has a constraint on a generic type parameter, the generic type must be the declaring typer of the method.");

					var index = Array.IndexOf(constraint.DeclaringType.GetGenericArguments(), constraint);
					Trace.Assert(index != -1, "The generic parameter comes from the given type.");
					return methodToCopyGenericsFrom.DeclaringType.GetGenericArguments()[index]; // these are the actual, concrete types
				}
			}
			else
			{
				return constraint;
			}
		}
开发者ID:jeremymeng,项目名称:Core,代码行数:44,代码来源:GenericUtil.cs


示例14: VerificationHelper

 private void VerificationHelper(GenericTypeParameterBuilder[] desiredParameters, Type[] actualParameters)
 {
     if (null == desiredParameters)
         Assert.Null(actualParameters);
     if (null != desiredParameters)
     {
         Assert.NotNull(actualParameters);
         Assert.Equal(desiredParameters.Length, actualParameters.Length);
         for (int i = 0; i < actualParameters.Length; ++i)
         {
             Assert.True(desiredParameters[i].Equals(actualParameters[i]));
         }
     }
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:14,代码来源:MethodBuilderGetGenericArguments.cs


示例15: Define

		/// <summary>
		///   This is the first method which is called during the resolving
		///   process; we're called immediately after creating the type parameters
		///   with SRE (by calling `DefineGenericParameters()' on the TypeBuilder /
		///   MethodBuilder).
		///
		///   We're either called from TypeContainer.DefineType() or from
		///   GenericMethod.Define() (called from Method.Define()).
		/// </summary>
		public void Define (GenericTypeParameterBuilder type)
		{
			if (this.type != null)
				throw new InvalidOperationException ();

			this.type = type;
			TypeManager.AddTypeParameter (type, this);
		}
开发者ID:lewurm,项目名称:benchmarker,代码行数:17,代码来源:generic.cs


示例16: UpdateGenericParameterContraints

 private static void UpdateGenericParameterContraints(RppGenericParameter genericParameter, GenericTypeParameterBuilder nativeGenericParameter)
 {
     if (genericParameter.Constraint != null)
     {
         if (genericParameter.Constraint.IsClass)
         {
             nativeGenericParameter.SetBaseTypeConstraint(genericParameter.Constraint.NativeType);
         }
         else
         {
             nativeGenericParameter.SetInterfaceConstraints(genericParameter.Constraint.NativeType);
         }
     }
 }
开发者ID:dubik,项目名称:csharprpp,代码行数:14,代码来源:RTypeUtils.cs


示例17: UpdateGenericParameter

 private static void UpdateGenericParameter(RppGenericParameter genericParameter, GenericTypeParameterBuilder nativeGenericParameter)
 {
     genericParameter.SetGenericTypeParameterBuilder(nativeGenericParameter);
     UpdateGenericParameterContraints(genericParameter, nativeGenericParameter);
 }
开发者ID:dubik,项目名称:csharprpp,代码行数:5,代码来源:RTypeUtils.cs


示例18: DefineGenericParameters

        void DefineGenericParameters(GenericTypeParameterBuilder[] builders, GenericParameterDeclaration[] declarations)
        {
            // Set builders
            for (int i = 0; i < builders.Length; i++)
            {
                SetBuilder(declarations[i], builders[i]);
            }

            // TODO: Set constraints
        }
开发者ID:w4x,项目名称:boolangstudio,代码行数:10,代码来源:EmitAssembly.cs


示例19: EmitConstraints

		public void EmitConstraints (GenericTypeParameterBuilder builder)
		{
			var attr = GenericParameterAttributes.None;
			if (spec.Variance == Variance.Contravariant)
				attr |= GenericParameterAttributes.Contravariant;
			else if (spec.Variance == Variance.Covariant)
				attr |= GenericParameterAttributes.Covariant;

			if (spec.HasSpecialClass)
				attr |= GenericParameterAttributes.ReferenceTypeConstraint;
			else if (spec.HasSpecialStruct)
				attr |= GenericParameterAttributes.NotNullableValueTypeConstraint | GenericParameterAttributes.DefaultConstructorConstraint;

			if (spec.HasSpecialConstructor)
				attr |= GenericParameterAttributes.DefaultConstructorConstraint;

			if (spec.BaseType != TypeManager.object_type)
				builder.SetBaseTypeConstraint (spec.BaseType.GetMetaInfo ());

			if (spec.InterfacesDefined != null)
				builder.SetInterfaceConstraints (spec.InterfacesDefined.Select (l => l.GetMetaInfo ()).ToArray ());

			if (spec.TypeArguments != null)
				builder.SetInterfaceConstraints (spec.TypeArguments.Select (l => l.GetMetaInfo ()).ToArray ());

			builder.SetGenericParameterAttributes (attr);
		}
开发者ID:ikvm,项目名称:mono,代码行数:27,代码来源:generic.cs


示例20: DefineGenericParameter

        private void DefineGenericParameter(InternalGenericParameter parameter, GenericTypeParameterBuilder builder)
        {
            // Set base type constraint
            if (parameter.BaseType != TypeSystemServices.ObjectType)
            {
                builder.SetBaseTypeConstraint(GetSystemType(parameter.BaseType));
            }

            // Set interface constraints
            Type[] interfaceTypes = Array.ConvertAll<IType, Type>(
                parameter.GetInterfaces(), GetSystemType);

            builder.SetInterfaceConstraints(interfaceTypes);

            // Set special attributes
            GenericParameterAttributes attributes = GenericParameterAttributes.None;
            if (parameter.IsClass)
                attributes |= GenericParameterAttributes.ReferenceTypeConstraint;
            if (parameter.IsValueType)
                attributes |= GenericParameterAttributes.NotNullableValueTypeConstraint;
            if (parameter.MustHaveDefaultConstructor)
                attributes |= GenericParameterAttributes.DefaultConstructorConstraint;

            builder.SetGenericParameterAttributes(attributes);
        }
开发者ID:Bombadil77,项目名称:boo,代码行数:25,代码来源:EmitAssembly.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Emit.ILGenerator类代码示例发布时间:2022-05-26
下一篇:
C# Emit.FieldBuilder类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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