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


C# IKVM.GetGenericArguments方法代码示例

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


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

示例1: InitTypeParameters

 static void InitTypeParameters(IKVM.Reflection.Type typeDefinition, ICollection<IUnresolvedTypeParameter> typeParameters)
 {
     // Type parameters are initialized within the constructor so that the class can be put into the type storage
     // before the rest of the initialization runs - this allows it to be available for early binding as soon as possible.
     var genericArguments = typeDefinition.GetGenericArguments ();
     for (int i = 0; i < genericArguments.Length; i++) {
         if (genericArguments[i].GenericParameterPosition != i)
             throw new InvalidOperationException("g.GenericParameterPosition != i");
         typeParameters.Add(new DefaultUnresolvedTypeParameter(
             EntityType.TypeDefinition, i, genericArguments [i].Name));
     }
 }
开发者ID:jlyonsmith,项目名称:NRefactory,代码行数:12,代码来源:IkvmLoader.cs

示例2: CreateTypeReference

        ITypeReference CreateTypeReference(IKVM.Reflection.Type type, IEnumerable<CustomAttributeData> typeAttributes, ref int typeIndex)
        {
            // TODO:
            //			while (type is OptionalModifierType || type is RequiredModifierType) {
            //				type = ((TypeSpecification)type).ElementType;
            //			}

            if (type == null) {
                return SpecialType.UnknownType;
            }

            if (type.IsByRef) {
                typeIndex++;
                return interningProvider.Intern (
                    new ByReferenceTypeReference (
                    CreateTypeReference (
                    type.GetElementType (),
                    typeAttributes, ref typeIndex)));
            }
            if (type.IsPointer) {
                typeIndex++;
                return interningProvider.Intern (
                    new PointerTypeReference (
                    CreateTypeReference (
                    type.GetElementType (),
                    typeAttributes, ref typeIndex)));
            }
            if (type.IsArray) {
                typeIndex++;
                return interningProvider.Intern (
                    new ArrayTypeReference (
                        CreateTypeReference (
                        type.GetElementType (),
                        typeAttributes, ref typeIndex),
                        type.GetArrayRank ()));
            }
            if (type.IsConstructedGenericType) {
                ITypeReference baseType = CreateTypeReference (type.GetGenericTypeDefinition (), typeAttributes, ref typeIndex);
                var args = type.GetGenericArguments ();
                var para = new ITypeReference[args.Length];
                for (int i = 0; i < para.Length; ++i) {
                    typeIndex++;
                    para [i] = CreateTypeReference (args [i], typeAttributes, ref typeIndex);
                }
                return interningProvider.Intern (new ParameterizedTypeReference (baseType, para));
            }
            if (type.IsGenericParameter) {
                return TypeParameterReference.Create (type.DeclaringMethod != null ? EntityType.Method : EntityType.TypeDefinition, type.GenericParameterPosition);
            }
            if (type.IsNested) {
                ITypeReference typeRef = CreateTypeReference (type.DeclaringType, typeAttributes, ref typeIndex);
                int partTypeParameterCount;
                string namepart = ReflectionHelper.SplitTypeParameterCountFromReflectionName (type.Name, out partTypeParameterCount);
                namepart = interningProvider.Intern (namepart);
                return interningProvider.Intern (new NestedTypeReference (typeRef, namepart, partTypeParameterCount));
            }

            string ns = interningProvider.Intern (type.Namespace ?? string.Empty);
            string name = type.Name;
            if (name == null)
                throw new InvalidOperationException ("type.Name returned null. Type: " + type);

            if (name == "Object" && ns == "System" && HasDynamicAttribute (typeAttributes, typeIndex)) {
                return SpecialType.Dynamic;
            }
            int typeParameterCount;
            name = ReflectionHelper.SplitTypeParameterCountFromReflectionName (name, out typeParameterCount);
            name = interningProvider.Intern (name);
            if (currentAssembly != null) {
                IUnresolvedTypeDefinition c = currentAssembly.GetTypeDefinition (ns, name, typeParameterCount);
                if (c != null)
                    return c;
            }
            return interningProvider.Intern (new GetClassTypeReference (GetAssemblyReference (type.Assembly), ns, name, typeParameterCount));
        }
开发者ID:jlyonsmith,项目名称:NRefactory,代码行数:75,代码来源:IkvmLoader.cs

示例3: InitTypeParameterConstraints

 void InitTypeParameterConstraints(IKVM.Reflection.Type typeDefinition, IList<IUnresolvedTypeParameter> typeParameters)
 {
     var args = typeDefinition.GetGenericArguments ();
     for (int i = 0; i < typeParameters.Count; i++) {
         var tp = (DefaultUnresolvedTypeParameter)typeParameters[i];
         AddConstraints(tp, args[i]);
         tp.ApplyInterningProvider(interningProvider);
     }
 }
开发者ID:jlyonsmith,项目名称:NRefactory,代码行数:9,代码来源:IkvmLoader.cs

示例4: GetUnderlyingType

 internal static IKVM.Reflection.Type GetUnderlyingType(IKVM.Reflection.Type type)
 {
     if (type.IsValueType && type.IsGenericType && type.GetGenericTypeDefinition().FullName == "System.Nullable`1")
     {
         return type.GetGenericArguments()[0];
     }
     return null;
 }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:8,代码来源:Helpers.cs


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