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


C# Emit.GenericTypeParameterBuilder类代码示例

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


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


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