예제 #1
0
        public ITypeInfo ReadType(MetadataSystem metadata)
        {
            var elementType = ReadElementType();
            var typeCode    = KnownType.GetTypeCode(elementType);

            if (typeCode != KnownTypeCode.None)
            {
                return(KnownType.GetType(typeCode));
            }

            switch (elementType)
            {
            case ElementType.ValueType: return(ReadValueType(metadata));

            case ElementType.Class: return(ReadClassType(metadata));

            case ElementType.ByRef: return(ReadByReferenceType(metadata));

            case ElementType.SizeArray: return(ReadVectorType(metadata));

            case ElementType.Array: return(ReadArrayType(metadata));

            case ElementType.Var: return(ReadTypeGenericParameter(metadata));

            case ElementType.MVar: return(ReadMethodGenericParameter(metadata));

            default: throw new NotSupportedException();
            }
        }
        public ElementType GetElementType(ITypeInfo type)
        {
            var knownTypeCode = KnownType.GetTypeCode(type);

            if (knownTypeCode != KnownTypeCode.None)
            {
                return(KnownType.GetElementType(knownTypeCode));
            }

            return(ElementType.Class);
        }