Microsoft.CSharp.RuntimeBinder.Semantics.CType.GetTypeKind C# (CSharp) Méthode

GetTypeKind() public méthode

public GetTypeKind ( ) : TypeKind
Résultat TypeKind
        public TypeKind GetTypeKind() { return _typeKind; }
        public void SetTypeKind(TypeKind kind) { _typeKind = kind; }

Usage Example

Exemple #1
0
        private static Type CalculateAssociatedSystemType(CType src)
        {
            Type result = null;

            switch (src.GetTypeKind())
            {
            case TypeKind.TK_ArrayType:
                ArrayType a           = (ArrayType)src;
                Type      elementType = a.GetElementType().AssociatedSystemType;
                result = a.IsSZArray ? elementType.MakeArrayType() : elementType.MakeArrayType(a.rank);
                break;

            case TypeKind.TK_NullableType:
                NullableType n = (NullableType)src;
                Type         underlyingType = n.GetUnderlyingType().AssociatedSystemType;
                result = typeof(Nullable <>).MakeGenericType(underlyingType);
                break;

            case TypeKind.TK_PointerType:
                PointerType p            = (PointerType)src;
                Type        referentType = p.GetReferentType().AssociatedSystemType;
                result = referentType.MakePointerType();
                break;

            case TypeKind.TK_ParameterModifierType:
                ParameterModifierType r = (ParameterModifierType)src;
                Type parameterType      = r.GetParameterType().AssociatedSystemType;
                result = parameterType.MakeByRefType();
                break;

            case TypeKind.TK_AggregateType:
                result = CalculateAssociatedSystemTypeForAggregate((AggregateType)src);
                break;

            case TypeKind.TK_TypeParameterType:
                TypeParameterType t = (TypeParameterType)src;
                if (t.IsMethodTypeParameter())
                {
                    MethodInfo meth = ((MethodSymbol)t.GetOwningSymbol()).AssociatedMemberInfo as MethodInfo;
                    result = meth.GetGenericArguments()[t.GetIndexInOwnParameters()];
                }
                else
                {
                    Type parentType = ((AggregateSymbol)t.GetOwningSymbol()).AssociatedSystemType;
                    result = parentType.GetGenericArguments()[t.GetIndexInOwnParameters()];
                }
                break;
            }

            Debug.Assert(result != null || src.GetTypeKind() == TypeKind.TK_AggregateType);
            return(result);
        }
All Usage Examples Of Microsoft.CSharp.RuntimeBinder.Semantics.CType::GetTypeKind