Beispiel #1
0
        public bool TryCreateTypeModel(
            TypeModelContainer container,
            Type type,
            [NotNullWhen(true)] out ITypeModel?typeModel)
        {
            typeModel = null;

            if (type == typeof(bool))
            {
                typeModel = new BoolTypeModel(container);
                return(true);
            }


            if (type == typeof(byte))
            {
                typeModel = new ByteTypeModel(container);
                return(true);
            }


            if (type == typeof(sbyte))
            {
                typeModel = new SByteTypeModel(container);
                return(true);
            }


            if (type == typeof(ushort))
            {
                typeModel = new UShortTypeModel(container);
                return(true);
            }


            if (type == typeof(short))
            {
                typeModel = new ShortTypeModel(container);
                return(true);
            }


            if (type == typeof(int))
            {
                typeModel = new IntTypeModel(container);
                return(true);
            }


            if (type == typeof(uint))
            {
                typeModel = new UIntTypeModel(container);
                return(true);
            }


            if (type == typeof(long))
            {
                typeModel = new LongTypeModel(container);
                return(true);
            }


            if (type == typeof(ulong))
            {
                typeModel = new ULongTypeModel(container);
                return(true);
            }


            if (type == typeof(float))
            {
                typeModel = new FloatTypeModel(container);
                return(true);
            }


            if (type == typeof(double))
            {
                typeModel = new DoubleTypeModel(container);
                return(true);
            }


            return(false);
        }
Beispiel #2
0
        public bool TryResolveFbsAlias(
            TypeModelContainer container,
            string alias,
            [NotNullWhen(true)] out ITypeModel?typeModel)
        {
            typeModel = null;
            switch (alias)
            {
            case "bool":
                typeModel = new BoolTypeModel(container);
                break;

            case "ubyte":
            case "uint8":
                typeModel = new ByteTypeModel(container);
                break;

            case "byte":
            case "int8":
                typeModel = new SByteTypeModel(container);
                break;

            case "ushort":
            case "uint16":
                typeModel = new UShortTypeModel(container);
                break;

            case "short":
            case "int16":
                typeModel = new ShortTypeModel(container);
                break;

            case "int":
            case "int32":
                typeModel = new IntTypeModel(container);
                break;

            case "uint":
            case "uint32":
                typeModel = new UIntTypeModel(container);
                break;

            case "long":
            case "int64":
                typeModel = new LongTypeModel(container);
                break;

            case "ulong":
            case "uint64":
                typeModel = new ULongTypeModel(container);
                break;

            case "float":
            case "float32":
                typeModel = new FloatTypeModel(container);
                break;

            case "double":
            case "float64":
                typeModel = new DoubleTypeModel(container);
                break;
            }

            return(typeModel is not null);
        }
        public bool TryCreateTypeModel(TypeModelContainer container, Type type, out ITypeModel typeModel)
        {
            typeModel = null;

            if (type == typeof(bool))
            {
                typeModel = new BoolTypeModel();
                return(true);
            }

            if (type == typeof(bool?))
            {
                typeModel = new NullableBoolTypeModel();
                return(true);
            }


            if (type == typeof(byte))
            {
                typeModel = new ByteTypeModel();
                return(true);
            }

            if (type == typeof(byte?))
            {
                typeModel = new NullableByteTypeModel();
                return(true);
            }


            if (type == typeof(sbyte))
            {
                typeModel = new SByteTypeModel();
                return(true);
            }

            if (type == typeof(sbyte?))
            {
                typeModel = new NullableSByteTypeModel();
                return(true);
            }


            if (type == typeof(ushort))
            {
                typeModel = new UShortTypeModel();
                return(true);
            }

            if (type == typeof(ushort?))
            {
                typeModel = new NullableUShortTypeModel();
                return(true);
            }


            if (type == typeof(short))
            {
                typeModel = new ShortTypeModel();
                return(true);
            }

            if (type == typeof(short?))
            {
                typeModel = new NullableShortTypeModel();
                return(true);
            }


            if (type == typeof(int))
            {
                typeModel = new IntTypeModel();
                return(true);
            }

            if (type == typeof(int?))
            {
                typeModel = new NullableIntTypeModel();
                return(true);
            }


            if (type == typeof(uint))
            {
                typeModel = new UIntTypeModel();
                return(true);
            }

            if (type == typeof(uint?))
            {
                typeModel = new NullableUIntTypeModel();
                return(true);
            }


            if (type == typeof(long))
            {
                typeModel = new LongTypeModel();
                return(true);
            }

            if (type == typeof(long?))
            {
                typeModel = new NullableLongTypeModel();
                return(true);
            }


            if (type == typeof(ulong))
            {
                typeModel = new ULongTypeModel();
                return(true);
            }

            if (type == typeof(ulong?))
            {
                typeModel = new NullableULongTypeModel();
                return(true);
            }


            if (type == typeof(float))
            {
                typeModel = new FloatTypeModel();
                return(true);
            }

            if (type == typeof(float?))
            {
                typeModel = new NullableFloatTypeModel();
                return(true);
            }


            if (type == typeof(double))
            {
                typeModel = new DoubleTypeModel();
                return(true);
            }

            if (type == typeof(double?))
            {
                typeModel = new NullableDoubleTypeModel();
                return(true);
            }


            return(false);
        }