/// <include file='doc\SoapSchemaImporter.uex' path='docs/doc[@for="SoapSchemaImporter.ImportMembersMapping"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public XmlMembersMapping ImportMembersMapping(string name, string ns, SoapSchemaMember member) { TypeMapping typeMapping = ImportType(member.MemberType, true); if (!(typeMapping is StructMapping)) { return(ImportMembersMapping(name, ns, new SoapSchemaMember[] { member })); } MembersMapping mapping = new MembersMapping(); mapping.TypeDesc = scope.GetTypeDesc(typeof(object[])); mapping.Members = ((StructMapping)typeMapping).Members; mapping.HasWrapperElement = true; ElementAccessor accessor = new ElementAccessor(); accessor.IsSoap = true; accessor.Name = Accessor.EscapeName(name, false); accessor.Namespace = typeMapping.Namespace != null ? typeMapping.Namespace : ns; accessor.Mapping = mapping; accessor.IsNullable = false; accessor.Form = XmlSchemaForm.Qualified; return(new XmlMembersMapping(scope, accessor)); }
static ElementAccessor CreateElementAccessor(TypeMapping mapping, string name, string ns) { ElementAccessor element = new ElementAccessor(); element.IsSoap = true; element.Name = Accessor.EscapeName(name == null ? mapping.TypeName : name, false); element.Namespace = ns; element.Mapping = mapping; return(element); }
void ImportAccessorMapping(MemberMapping accessor, FieldModel model, SoapAttributes a, string ns, XmlSchemaForm form) { Type accessorType = model.FieldType; string accessorName = model.Name; accessor.TypeDesc = typeScope.GetTypeDesc(accessorType); if (accessor.TypeDesc.IsVoid) { throw new InvalidOperationException(Res.GetString(Res.XmlInvalidVoid)); } SoapAttributeFlags flags = a.SoapFlags; if ((flags & SoapAttributeFlags.Attribute) == SoapAttributeFlags.Attribute) { if (!accessor.TypeDesc.IsPrimitive && !accessor.TypeDesc.IsEnum) { throw new InvalidOperationException(Res.GetString(Res.XmlIllegalAttrOrText)); } if ((flags & SoapAttributeFlags.Attribute) != flags) { throw new InvalidOperationException(Res.GetString(Res.XmlInvalidElementAttribute)); } AttributeAccessor attribute = new AttributeAccessor(); attribute.Name = Accessor.EscapeName(a.SoapAttribute == null || a.SoapAttribute.AttributeName.Length == 0 ? accessorName : a.SoapAttribute.AttributeName, true); attribute.Namespace = a.SoapAttribute == null || a.SoapAttribute.Namespace == null ? ns : a.SoapAttribute.Namespace; attribute.Form = XmlSchemaForm.Qualified; // attributes are always qualified since they're only used for encoded soap headers attribute.Mapping = ImportTypeMapping(modelScope.GetTypeModel(accessorType), (a.SoapAttribute == null ? String.Empty : a.SoapAttribute.DataType)); attribute.Default = GetDefaultValue(model.FieldTypeDesc, a); accessor.Attribute = attribute; accessor.Elements = new ElementAccessor[0]; } else { if ((flags & SoapAttributeFlags.Element) != flags) { throw new InvalidOperationException(Res.GetString(Res.XmlInvalidElementAttribute)); } ElementAccessor element = new ElementAccessor(); element.IsSoap = true; element.Name = Accessor.EscapeName(a.SoapElement == null || a.SoapElement.ElementName.Length == 0 ? accessorName : a.SoapElement.ElementName, false); element.Namespace = ns; element.Form = form; element.Mapping = ImportTypeMapping(modelScope.GetTypeModel(accessorType), (a.SoapElement == null ? String.Empty : a.SoapElement.DataType)); if (a.SoapElement != null) { element.IsNullable = a.SoapElement.IsNullable; } accessor.Elements = new ElementAccessor[] { element }; } }
/// <include file='doc\SoapReflectionImporter.uex' path='docs/doc[@for="XmlReflectionImporter.ImportTypeMapping1"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public XmlTypeMapping ImportTypeMapping(Type type, string defaultNamespace) { ElementAccessor element = new ElementAccessor(); element.IsSoap = true; element.Mapping = ImportTypeMapping(modelScope.GetTypeModel(type)); element.Name = Accessor.EscapeName(element.Mapping.TypeName, false); element.Namespace = element.Mapping.Namespace == null ? defaultNamespace : element.Mapping.Namespace; element.Form = XmlSchemaForm.Qualified; XmlTypeMapping xmlMapping = new XmlTypeMapping(typeScope, element); xmlMapping.GenerateSerializer = true; return(xmlMapping); }
/// <include file='doc\SoapReflectionImporter.uex' path='docs/doc[@for="SoapReflectionImporter.ImportMembersMapping2"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public XmlMembersMapping ImportMembersMapping(string elementName, string ns, XmlReflectionMember[] members, bool hasWrapperElement, bool writeAccessors, bool validate) { ElementAccessor element = new ElementAccessor(); element.IsSoap = true; element.Name = Accessor.EscapeName(elementName, false); element.Mapping = ImportMembersMapping(members, ns, hasWrapperElement, writeAccessors, validate); element.Mapping.TypeName = elementName; element.Namespace = element.Mapping.Namespace == null ? ns : element.Mapping.Namespace; element.Form = XmlSchemaForm.Qualified; XmlMembersMapping xmlMapping = new XmlMembersMapping(typeScope, element); xmlMapping.GenerateSerializer = true; return(xmlMapping); }
/// <include file='doc\SoapSchemaImporter.uex' path='docs/doc[@for="SoapSchemaImporter.ImportMembersMapping3"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public XmlMembersMapping ImportMembersMapping(string name, string ns, SoapSchemaMember[] members, bool hasWrapperElement, Type baseType, bool baseTypeCanBeIndirect) { XmlSchemaComplexType type = new XmlSchemaComplexType(); XmlSchemaSequence seq = new XmlSchemaSequence(); type.Particle = seq; foreach (SoapSchemaMember member in members) { XmlSchemaElement element = new XmlSchemaElement(); element.Name = Accessor.EscapeName(member.MemberName, false); element.SchemaTypeName = member.MemberType; seq.Items.Add(element); } CodeIdentifiers identifiers = new CodeIdentifiers(); identifiers.UseCamelCasing = true; MembersMapping mapping = new MembersMapping(); mapping.TypeDesc = scope.GetTypeDesc(typeof(object[])); mapping.Members = ImportTypeMembers(type, ns, identifiers); mapping.HasWrapperElement = hasWrapperElement; if (baseType != null) { for (int i = 0; i < mapping.Members.Length; i++) { MemberMapping member = mapping.Members[i]; if (member.Accessor.Mapping is StructMapping) { MakeDerived((StructMapping)member.Accessor.Mapping, baseType, baseTypeCanBeIndirect); } } } ElementAccessor accessor = new ElementAccessor(); accessor.IsSoap = true; accessor.Name = Accessor.EscapeName(name, false); accessor.Namespace = ns; accessor.Mapping = mapping; accessor.IsNullable = false; accessor.Form = XmlSchemaForm.Qualified; return(new XmlMembersMapping(scope, accessor)); }
/// <include file='doc\SoapSchemaImporter.uex' path='docs/doc[@for="SoapSchemaImporter.ImportDerivedTypeMapping"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public XmlTypeMapping ImportDerivedTypeMapping(XmlQualifiedName name, Type baseType, bool baseTypeCanBeIndirect) { TypeMapping mapping = ImportType(name, false); if (mapping is StructMapping) { MakeDerived((StructMapping)mapping, baseType, baseTypeCanBeIndirect); } else if (baseType != null) { throw new InvalidOperationException(Res.GetString(Res.XmlPrimitiveBaseType, name.Name, name.Namespace, baseType.FullName)); } ElementAccessor accessor = new ElementAccessor(); accessor.IsSoap = true; accessor.Name = Accessor.EscapeName(name.Name, false); accessor.Namespace = name.Namespace; accessor.Mapping = mapping; accessor.IsNullable = true; accessor.Form = XmlSchemaForm.Qualified; return(new XmlTypeMapping(scope, accessor)); }