Пример #1
0
        public NetType GetPrimitiveType(PrimitiveTypeCode typeCode)
        {
            switch (typeCode)
            {
            case PrimitiveTypeCode.Boolean:
                return(_factory.CreateTypeModel(TypeKey.FromType <bool>()));

            case PrimitiveTypeCode.Byte:
                return(_factory.CreateTypeModel(TypeKey.FromType <byte>()));

            case PrimitiveTypeCode.SByte:
                return(_factory.CreateTypeModel(TypeKey.FromType <sbyte>()));

            case PrimitiveTypeCode.Char:
                return(_factory.CreateTypeModel(TypeKey.FromType <char>()));

            case PrimitiveTypeCode.Int16:
                return(_factory.CreateTypeModel(TypeKey.FromType <short>()));

            case PrimitiveTypeCode.UInt16:
                return(_factory.CreateTypeModel(TypeKey.FromType <ushort>()));

            case PrimitiveTypeCode.Int32:
                return(_factory.CreateTypeModel(TypeKey.FromType <int>()));

            case PrimitiveTypeCode.UInt32:
                return(_factory.CreateTypeModel(TypeKey.FromType <uint>()));

            case PrimitiveTypeCode.Int64:
                return(_factory.CreateTypeModel(TypeKey.FromType <long>()));

            case PrimitiveTypeCode.UInt64:
                return(_factory.CreateTypeModel(TypeKey.FromType <ulong>()));

            case PrimitiveTypeCode.Single:
                return(_factory.CreateTypeModel(TypeKey.FromType <float>()));

            case PrimitiveTypeCode.Double:
                return(_factory.CreateTypeModel(TypeKey.FromType <double>()));

            case PrimitiveTypeCode.IntPtr:
                return(_factory.CreateTypeModel(TypeKey.FromType <IntPtr>()));

            case PrimitiveTypeCode.UIntPtr:
                return(_factory.CreateTypeModel(TypeKey.FromType <UIntPtr>()));

            case PrimitiveTypeCode.Object:
                return(_factory.CreateTypeModel(TypeKey.FromType <object>()));

            case PrimitiveTypeCode.String:
                return(_factory.CreateTypeModel(TypeKey.FromType <string>()));

            case PrimitiveTypeCode.TypedReference:
                // todo: not sure
                return(_factory.CreateTypeModel(TypeKey.FromType <TypeReference>()));

            case PrimitiveTypeCode.Void:
                return(_factory.CreateTypeModel(TypeKey.FromType(typeof(void))));

            default:
                throw new ArgumentOutOfRangeException(nameof(typeCode), typeCode, null);
            }
        }