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; }
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; }
public ArrayModel GetArrayModel(Type type) { TypeModel model = (TypeModel) arrayModels[type]; if (model == null) { model = GetTypeModel(type); if (!(model is ArrayModel)) { TypeDesc typeDesc = typeScope.GetArrayTypeDesc(type); model = new ArrayModel(type, typeDesc, this); } arrayModels.Add(type, model); } return (ArrayModel) model; }
internal ArrayModel GetArrayModel(Type type) { TypeModel model; if (!_arrayModels.TryGetValue(type, out model)) { model = GetTypeModel(type); if (!(model is ArrayModel)) { TypeDesc typeDesc = _typeScope.GetArrayTypeDesc(type); model = new ArrayModel(type, typeDesc, this); } _arrayModels.Add(type, model); } return (ArrayModel)model; }
internal ArrayModel GetArrayModel(Type type) { TypeModel typeModel = (TypeModel) this.arrayModels[type]; if (typeModel == null) { typeModel = this.GetTypeModel(type); if (!(typeModel is ArrayModel)) { TypeDesc arrayTypeDesc = this.typeScope.GetArrayTypeDesc(type); typeModel = new ArrayModel(type, arrayTypeDesc, this); } this.arrayModels.Add(type, typeModel); } return (ArrayModel) typeModel; }
internal ArrayModel GetArrayModel(Type type) { TypeModel model = (TypeModel)arrayModels[type]; if (model == null) { model = GetTypeModel(type); if (!(model is ArrayModel)) { TypeDesc typeDesc = typeScope.GetArrayTypeDesc(type); model = new ArrayModel(type, typeDesc, this); } arrayModels.Add(type, model); } return((ArrayModel)model); }
internal ArrayModel GetArrayModel(Type type) { TypeModel?model; if (!_arrayModels.TryGetValue(type, out model)) { model = GetTypeModel(type); if (!(model is ArrayModel)) { TypeDesc typeDesc = _typeScope.GetArrayTypeDesc(type); model = new ArrayModel(type, typeDesc, this); } _arrayModels.Add(type, model); } return((ArrayModel)model); }
internal ArrayModel GetArrayModel(Type type) { TypeModel typeModel = (TypeModel)this.arrayModels[type]; if (typeModel == null) { typeModel = this.GetTypeModel(type); if (!(typeModel is ArrayModel)) { TypeDesc arrayTypeDesc = this.typeScope.GetArrayTypeDesc(type); typeModel = new ArrayModel(type, arrayTypeDesc, this); } this.arrayModels.Add(type, typeModel); } return((ArrayModel)typeModel); }
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); }
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); }
private ArrayMapping ImportArrayLikeMapping(ArrayModel model, RecursionLimiter limiter) { ArrayMapping mapping = new ArrayMapping(); mapping.IsSoap = true; TypeMapping itemTypeMapping = ImportTypeMapping(model.Element, limiter); if (itemTypeMapping.TypeDesc.IsValueType && !itemTypeMapping.TypeDesc.IsPrimitive && !itemTypeMapping.TypeDesc.IsEnum) { throw new NotSupportedException(SR.Format(SR.XmlRpcArrayOfValueTypes, model.TypeDesc.FullName)); } mapping.TypeDesc = model.TypeDesc; mapping.Elements = new ElementAccessor[] { CreateElementAccessor(itemTypeMapping, mapping.Namespace) }; SetArrayMappingType(mapping); // in the case of an ArrayMapping we can have more that one mapping correspond to a type // examples of that are ArrayList and object[] both will map tp ArrayOfur-type // so we create a link list for all mappings of the same XSD type ArrayMapping existingMapping = (ArrayMapping)_types[mapping.TypeName, mapping.Namespace]; if (existingMapping != null) { ArrayMapping first = existingMapping; while (existingMapping != null) { if (existingMapping.TypeDesc == model.TypeDesc) { return(existingMapping); } existingMapping = existingMapping.Next; } mapping.Next = first; _types[mapping.TypeName, mapping.Namespace] = mapping; return(mapping); } _typeScope.AddTypeMapping(mapping); _types.Add(mapping.TypeName, mapping.Namespace, mapping); IncludeTypes(model.Type); return(mapping); }
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; }
private ArrayMapping ImportArrayLikeMapping(ArrayModel model, RecursionLimiter limiter) { ArrayMapping mapping = new ArrayMapping { IsSoap = true }; TypeMapping mapping2 = this.ImportTypeMapping(model.Element, limiter); if ((mapping2.TypeDesc.IsValueType && !mapping2.TypeDesc.IsPrimitive) && !mapping2.TypeDesc.IsEnum) { throw new NotSupportedException(Res.GetString("XmlRpcArrayOfValueTypes", new object[] { model.TypeDesc.FullName })); } mapping.TypeDesc = model.TypeDesc; mapping.Elements = new ElementAccessor[] { CreateElementAccessor(mapping2, mapping.Namespace) }; this.SetArrayMappingType(mapping); ArrayMapping next = (ArrayMapping)this.types[mapping.TypeName, mapping.Namespace]; if (next != null) { ArrayMapping mapping4 = next; while (next != null) { if (next.TypeDesc == model.TypeDesc) { return(next); } next = next.Next; } mapping.Next = mapping4; this.types[mapping.TypeName, mapping.Namespace] = mapping; return(mapping); } this.typeScope.AddTypeMapping(mapping); this.types.Add(mapping.TypeName, mapping.Namespace, mapping); this.IncludeTypes(model.Type); return(mapping); }
private ArrayMapping ImportArrayLikeMapping(ArrayModel model, string ns, RecursionLimiter limiter) { ArrayMapping arrayMapping = new ArrayMapping { TypeDesc = model.TypeDesc }; if (this.savedArrayItemAttributes == null) { this.savedArrayItemAttributes = new XmlArrayItemAttributes(); } if (CountAtLevel(this.savedArrayItemAttributes, this.arrayNestingLevel) == 0) { this.savedArrayItemAttributes.Add(CreateArrayItemAttribute(this.typeScope.GetTypeDesc(model.Element.Type), this.arrayNestingLevel)); } this.CreateArrayElementsFromAttributes(arrayMapping, this.savedArrayItemAttributes, model.Element.Type, (this.savedArrayNamespace == null) ? ns : this.savedArrayNamespace, limiter); this.SetArrayMappingType(arrayMapping, ns, model.Type); for (int i = 0; i < arrayMapping.Elements.Length; i++) { arrayMapping.Elements[i] = this.ReconcileLocalAccessor(arrayMapping.Elements[i], arrayMapping.Namespace); } this.IncludeTypes(model.Type); ArrayMapping next = (ArrayMapping) this.types[arrayMapping.TypeName, arrayMapping.Namespace]; if (next != null) { ArrayMapping mapping3 = next; while (next != null) { if (next.TypeDesc == model.TypeDesc) { return next; } next = next.Next; } arrayMapping.Next = mapping3; if (!arrayMapping.IsAnonymousType) { this.types[arrayMapping.TypeName, arrayMapping.Namespace] = arrayMapping; return arrayMapping; } this.anonymous[model.Type] = arrayMapping; return arrayMapping; } this.typeScope.AddTypeMapping(arrayMapping); if (!arrayMapping.IsAnonymousType) { this.types.Add(arrayMapping.TypeName, arrayMapping.Namespace, arrayMapping); return arrayMapping; } this.anonymous[model.Type] = arrayMapping; return arrayMapping; }
ArrayMapping ImportArrayLikeMapping(ArrayModel model) { ArrayMapping mapping = new ArrayMapping(); mapping.IsSoap = true; TypeMapping itemTypeMapping = ImportTypeMapping(model.Element); if (itemTypeMapping.TypeDesc.IsValueType && !itemTypeMapping.TypeDesc.IsPrimitive && !itemTypeMapping.TypeDesc.IsEnum) throw new NotSupportedException(Res.GetString(Res.XmlRpcArrayOfValueTypes, model.TypeDesc.FullName)); mapping.TypeDesc = model.TypeDesc; mapping.Elements = new ElementAccessor[] { CreateElementAccessor(itemTypeMapping, mapping.Namespace) }; SetArrayMappingType(mapping); // in the case of an ArrayMapping we can have more that one mapping correspond to a type // examples of that are ArrayList and object[] both will map tp ArrayOfur-type // so we create a link list for all mappings of the same XSD type ArrayMapping existingMapping = (ArrayMapping)types[mapping.TypeName, mapping.Namespace]; if (existingMapping != null) { ArrayMapping first = existingMapping; while (existingMapping != null) { if (existingMapping.TypeDesc == model.TypeDesc) return existingMapping; existingMapping = existingMapping.Next; } mapping.Next = first; types[mapping.TypeName, mapping.Namespace] = mapping; return mapping; } typeScope.AddTypeMapping(mapping); types.Add(mapping.TypeName, mapping.Namespace, mapping); IncludeTypes(model.Type); return mapping; }
ArrayMapping ImportArrayLikeMapping(ArrayModel model, string ns) { ArrayMapping mapping = new ArrayMapping(); mapping.TypeDesc = model.TypeDesc; if (savedArrayItemAttributes == null) savedArrayItemAttributes = new XmlArrayItemAttributes(); if (CountAtLevel(savedArrayItemAttributes, arrayNestingLevel) == 0) savedArrayItemAttributes.Add(CreateArrayItemAttribute(typeScope.GetTypeDesc(model.Element.Type), arrayNestingLevel)); CreateArrayElementsFromAttributes(mapping, savedArrayItemAttributes, model.Element.Type, savedArrayNamespace == null ? ns : savedArrayNamespace); SetArrayMappingType(mapping, ns, model.Type); // reconcile accessors now that we have the ArrayMapping namespace for (int i = 0; i < mapping.Elements.Length; i++) { mapping.Elements[i] = ReconcileLocalAccessor(mapping.Elements[i], mapping.Namespace); } IncludeTypes(model.Type); // in the case of an ArrayMapping we can have more that one mapping correspond to a type // examples of that are ArrayList and object[] both will map tp ArrayOfur-type // so we create a link list for all mappings of the same XSD type ArrayMapping existingMapping = (ArrayMapping)types[mapping.TypeName, mapping.Namespace]; if (existingMapping != null) { ArrayMapping first = existingMapping; while (existingMapping != null) { if (existingMapping.TypeDesc == model.TypeDesc) return existingMapping; existingMapping = existingMapping.Next; } mapping.Next = first; if (!mapping.IsAnonymousType) types[mapping.TypeName, mapping.Namespace] = mapping; else anonymous[model.Type] = mapping; return mapping; } typeScope.AddTypeMapping(mapping); if (!mapping.IsAnonymousType) types.Add(mapping.TypeName, mapping.Namespace, mapping); else anonymous[model.Type] = mapping; return mapping; }