Inheritance: TypeModel
Beispiel #1
0
        internal TypeModel GetTypeModel(Type type, bool directReference)
        {
            TypeModel model;
            if (_models.TryGetValue(type, out model))
                return model;
            TypeDesc typeDesc = _typeScope.GetTypeDesc(type, null, directReference);

            switch (typeDesc.Kind)
            {
                case TypeKind.Enum:
                    model = new EnumModel(type, typeDesc, this);
                    break;
                case TypeKind.Primitive:
                    model = new PrimitiveModel(type, typeDesc, this);
                    break;
                case TypeKind.Array:
                case TypeKind.Collection:
                case TypeKind.Enumerable:
                    model = new ArrayModel(type, typeDesc, this);
                    break;
                case TypeKind.Root:
                case TypeKind.Class:
                case TypeKind.Struct:
                    model = new StructModel(type, typeDesc, this);
                    break;
                default:
                    if (!typeDesc.IsSpecial) throw new NotSupportedException(SR.Format(SR.XmlUnsupportedTypeKind, type.FullName));
                    model = new SpecialModel(type, typeDesc, this);
                    break;
            }

            _models.Add(type, model);
            return model;
        }
Beispiel #2
0
        public TypeModel GetTypeModel(Type type) {
            TypeModel model = (TypeModel)models[type];
            if (model != null) return model;
            TypeDesc typeDesc = typeScope.GetTypeDesc(type);

            switch (typeDesc.Kind) {
                case TypeKind.Enum: 
                    model = new EnumModel(type, typeDesc, this);
                    break;
                case TypeKind.Primitive:
                    model = new PrimitiveModel(type, typeDesc, this);
                    break;
                case TypeKind.Array:
                case TypeKind.Collection:
                case TypeKind.Enumerable:
                    model = new ArrayModel(type, typeDesc, this);
                    break;
                case TypeKind.Root:
                case TypeKind.Class:
                case TypeKind.Struct:
                case TypeKind.Interface:
                    model = new StructModel(type, typeDesc, this);
                    break;
                default:
                    if (!typeDesc.IsSpecial) throw new NotSupportedException(Res.GetString(Res.XmlUnsupportedTypeKind, type.FullName));
                    model = new SpecialModel(type, typeDesc, this);
                    break;
            }

            models.Add(type, model);
            return model;
        }
Beispiel #3
0
        public TypeModel GetTypeModel(Type type)
        {
            TypeModel model = (TypeModel)models[type];

            if (model != null)
            {
                return(model);
            }
            TypeDesc typeDesc = typeScope.GetTypeDesc(type);

            switch (typeDesc.Kind)
            {
            case TypeKind.Enum:
                model = new EnumModel(type, typeDesc, this);
                break;

            case TypeKind.Primitive:
                model = new PrimitiveModel(type, typeDesc, this);
                break;

            case TypeKind.Array:
            case TypeKind.Collection:
            case TypeKind.Enumerable:
                model = new ArrayModel(type, typeDesc, this);
                break;

            case TypeKind.Root:
            case TypeKind.Class:
            case TypeKind.Struct:
            case TypeKind.Interface:
                model = new StructModel(type, typeDesc, this);
                break;

            default:
                if (!typeDesc.IsSpecial)
                {
                    throw new NotSupportedException(Res.GetString(Res.XmlUnsupportedTypeKind, type.FullName));
                }
                model = new SpecialModel(type, typeDesc, this);
                break;
            }

            models.Add(type, model);
            return(model);
        }
Beispiel #4
0
        internal TypeModel GetTypeModel(Type type, bool directReference)
        {
            TypeModel?model;

            if (_models.TryGetValue(type, out model))
            {
                return(model);
            }
            TypeDesc typeDesc = _typeScope.GetTypeDesc(type, null, directReference);

            switch (typeDesc.Kind)
            {
            case TypeKind.Enum:
                model = new EnumModel(type, typeDesc, this);
                break;

            case TypeKind.Primitive:
                model = new PrimitiveModel(type, typeDesc, this);
                break;

            case TypeKind.Array:
            case TypeKind.Collection:
            case TypeKind.Enumerable:
                model = new ArrayModel(type, typeDesc, this);
                break;

            case TypeKind.Root:
            case TypeKind.Class:
            case TypeKind.Struct:
                model = new StructModel(type, typeDesc, this);
                break;

            default:
                if (!typeDesc.IsSpecial)
                {
                    throw new NotSupportedException(SR.Format(SR.XmlUnsupportedTypeKind, type.FullName));
                }
                model = new SpecialModel(type, typeDesc, this);
                break;
            }

            _models.Add(type, model);
            return(model);
        }
        internal TypeModel GetTypeModel(Type type, bool directReference)
        {
            TypeModel model = (TypeModel)this.models[type];

            if (model == null)
            {
                TypeDesc typeDesc = this.typeScope.GetTypeDesc(type, null, directReference);
                switch (typeDesc.Kind)
                {
                case TypeKind.Root:
                case TypeKind.Struct:
                case TypeKind.Class:
                    model = new StructModel(type, typeDesc, this);
                    break;

                case TypeKind.Primitive:
                    model = new PrimitiveModel(type, typeDesc, this);
                    break;

                case TypeKind.Enum:
                    model = new EnumModel(type, typeDesc, this);
                    break;

                case TypeKind.Array:
                case TypeKind.Collection:
                case TypeKind.Enumerable:
                    model = new ArrayModel(type, typeDesc, this);
                    break;

                default:
                    if (!typeDesc.IsSpecial)
                    {
                        throw new NotSupportedException(Res.GetString("XmlUnsupportedTypeKind", new object[] { type.FullName }));
                    }
                    model = new SpecialModel(type, typeDesc, this);
                    break;
                }
                this.models.Add(type, model);
            }
            return(model);
        }
        internal TypeModel GetTypeModel(Type type, bool directReference)
        {
            TypeModel model = (TypeModel) this.models[type];
            if (model == null)
            {
                TypeDesc typeDesc = this.typeScope.GetTypeDesc(type, null, directReference);
                switch (typeDesc.Kind)
                {
                    case TypeKind.Root:
                    case TypeKind.Struct:
                    case TypeKind.Class:
                        model = new StructModel(type, typeDesc, this);
                        break;

                    case TypeKind.Primitive:
                        model = new PrimitiveModel(type, typeDesc, this);
                        break;

                    case TypeKind.Enum:
                        model = new EnumModel(type, typeDesc, this);
                        break;

                    case TypeKind.Array:
                    case TypeKind.Collection:
                    case TypeKind.Enumerable:
                        model = new ArrayModel(type, typeDesc, this);
                        break;

                    default:
                        if (!typeDesc.IsSpecial)
                        {
                            throw new NotSupportedException(Res.GetString("XmlUnsupportedTypeKind", new object[] { type.FullName }));
                        }
                        model = new SpecialModel(type, typeDesc, this);
                        break;
                }
                this.models.Add(type, model);
            }
            return model;
        }