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


C# GenericTypeParameterBuilder.SetBaseTypeConstraint方法代码示例

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


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

示例3: 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

示例4: 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

示例5: 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

示例6: SetConstraints

		public void SetConstraints (GenericTypeParameterBuilder type)
		{
			GenericParameterAttributes attr = GenericParameterAttributes.None;
			if (variance == Variance.Contravariant)
				attr |= GenericParameterAttributes.Contravariant;
			else if (variance == Variance.Covariant)
				attr |= GenericParameterAttributes.Covariant;

			if (gc != null) {
				if (gc.HasClassConstraint || gc.HasValueTypeConstraint)
					type.SetBaseTypeConstraint (gc.EffectiveBaseClass);

				attr |= gc.Attributes;
				type.SetInterfaceConstraints (gc.InterfaceConstraints);
				TypeManager.RegisterBuilder (type, gc.InterfaceConstraints);
			}
			
			type.SetGenericParameterAttributes (attr);
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:19,代码来源:generic.cs


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