private void ImportGroupMembers(XmlSchemaParticle particle, CodeIdentifiers members, string ns) { XmlQualifiedName parentType = XmlSchemas.GetParentName(particle); if (particle is XmlSchemaGroupRef) { throw new InvalidOperationException(SR.Format(SR.XmlSoapUnsupportedGroupRef, parentType.Name, parentType.Namespace)); } else if (particle is XmlSchemaGroupBase) { XmlSchemaGroupBase group = (XmlSchemaGroupBase)particle; if (group.IsMultipleOccurrence) { throw new InvalidOperationException(SR.Format(SR.XmlSoapUnsupportedGroupRepeat, parentType.Name, parentType.Namespace)); } for (int i = 0; i < group.Items.Count; i++) { object item = group.Items[i]; if (item is XmlSchemaGroupBase || item is XmlSchemaGroupRef) { throw new InvalidOperationException(SR.Format(SR.XmlSoapUnsupportedGroupNested, parentType.Name, parentType.Namespace)); } else if (item is XmlSchemaElement) { ImportElementMember((XmlSchemaElement)item, members, ns); } else if (item is XmlSchemaAny) { throw new InvalidOperationException(SR.Format(SR.XmlSoapUnsupportedGroupAny, parentType.Name, parentType.Namespace)); } } } }
private void ImportGroupMembers(XmlSchemaParticle particle, CodeIdentifiers members, string ns) { XmlQualifiedName parentName = XmlSchemas.GetParentName(particle); if (particle is XmlSchemaGroupRef) { throw new InvalidOperationException(Res.GetString("XmlSoapUnsupportedGroupRef", new object[] { parentName.Name, parentName.Namespace })); } if (particle is XmlSchemaGroupBase) { XmlSchemaGroupBase base2 = (XmlSchemaGroupBase)particle; if (base2.IsMultipleOccurrence) { throw new InvalidOperationException(Res.GetString("XmlSoapUnsupportedGroupRepeat", new object[] { parentName.Name, parentName.Namespace })); } for (int i = 0; i < base2.Items.Count; i++) { object obj2 = base2.Items[i]; if ((obj2 is XmlSchemaGroupBase) || (obj2 is XmlSchemaGroupRef)) { throw new InvalidOperationException(Res.GetString("XmlSoapUnsupportedGroupNested", new object[] { parentName.Name, parentName.Namespace })); } if (obj2 is XmlSchemaElement) { this.ImportElementMember((XmlSchemaElement)obj2, members, ns); } else if (obj2 is XmlSchemaAny) { throw new InvalidOperationException(Res.GetString("XmlSoapUnsupportedGroupAny", new object[] { parentName.Name, parentName.Namespace })); } } } }
private void ImportGroup(XmlSchemaParticle group, CodeIdentifiers members, string ns) { if (group is XmlSchemaChoice) { XmlQualifiedName parentName = XmlSchemas.GetParentName(group); throw new InvalidOperationException(Res.GetString("XmlSoapInvalidChoice", new object[] { parentName.Name, parentName.Namespace })); } this.ImportGroupMembers(group, members, ns); }
private void ImportGroup(XmlSchemaParticle group, CodeIdentifiers members, string ns) { if (group is XmlSchemaChoice) { XmlQualifiedName parentType = XmlSchemas.GetParentName(group); throw new InvalidOperationException(SR.Format(SR.XmlSoapInvalidChoice, parentType.Name, parentType.Namespace)); } else { ImportGroupMembers(group, members, ns); } }
private ElementAccessor ImportElement(XmlSchemaElement element, string ns) { if (!element.RefName.IsEmpty) { throw new InvalidOperationException(Res.GetString("RefSyntaxNotSupportedForElements0", new object[] { element.RefName.Name, element.RefName.Namespace })); } if (element.Name.Length == 0) { XmlQualifiedName parentName = XmlSchemas.GetParentName(element); throw new InvalidOperationException(Res.GetString("XmlElementHasNoName", new object[] { parentName.Name, parentName.Namespace })); } TypeMapping mapping = this.ImportElementType(element, ns); return(new ElementAccessor { IsSoap = true, Name = element.Name, Namespace = ns, Mapping = mapping, IsNullable = element.IsNillable, Form = XmlSchemaForm.None }); }
private TypeMapping ImportElementType(XmlSchemaElement element, string ns) { TypeMapping mapping; if (!element.SchemaTypeName.IsEmpty) { mapping = ImportType(element.SchemaTypeName, false); } else if (element.SchemaType != null) { XmlQualifiedName parentType = XmlSchemas.GetParentName(element); if (element.SchemaType is XmlSchemaComplexType) { mapping = ImportType((XmlSchemaComplexType)element.SchemaType, ns, false); if (!(mapping is ArrayMapping)) { throw new InvalidOperationException(SR.Format(SR.XmlInvalidSchemaElementType, parentType.Name, parentType.Namespace, element.Name)); } } else { throw new InvalidOperationException(SR.Format(SR.XmlInvalidSchemaElementType, parentType.Name, parentType.Namespace, element.Name)); } } else if (!element.SubstitutionGroup.IsEmpty) { XmlQualifiedName parentType = XmlSchemas.GetParentName(element); throw new InvalidOperationException(SR.Format(SR.XmlInvalidSubstitutionGroupUse, parentType.Name, parentType.Namespace)); } else { XmlQualifiedName parentType = XmlSchemas.GetParentName(element); throw new InvalidOperationException(SR.Format(SR.XmlElementMissingType, parentType.Name, parentType.Namespace, element.Name)); } mapping.ReferencedByElement = true; return(mapping); }
private ElementAccessor ImportElement(XmlSchemaElement element, string ns) { if (!element.RefName.IsEmpty) { throw new InvalidOperationException(SR.Format(SR.RefSyntaxNotSupportedForElements0, element.RefName.Name, element.RefName.Namespace)); } if (element.Name.Length == 0) { XmlQualifiedName parentType = XmlSchemas.GetParentName(element); throw new InvalidOperationException(SR.Format(SR.XmlElementHasNoName, parentType.Name, parentType.Namespace)); } TypeMapping mapping = ImportElementType(element, ns); ElementAccessor accessor = new ElementAccessor(); accessor.IsSoap = true; accessor.Name = element.Name; accessor.Namespace = ns; accessor.Mapping = mapping; accessor.IsNullable = element.IsNillable; accessor.Form = XmlSchemaForm.None; return(accessor); }
private TypeMapping ImportElementType(XmlSchemaElement element, string ns) { TypeMapping mapping; if (!element.SchemaTypeName.IsEmpty) { mapping = this.ImportType(element.SchemaTypeName, false); } else { if (element.SchemaType != null) { XmlQualifiedName name = XmlSchemas.GetParentName(element); if (element.SchemaType is XmlSchemaComplexType) { mapping = this.ImportType((XmlSchemaComplexType)element.SchemaType, ns, false); if (!(mapping is ArrayMapping)) { throw new InvalidOperationException(Res.GetString("XmlInvalidSchemaElementType", new object[] { name.Name, name.Namespace, element.Name })); } goto Label_014F; } throw new InvalidOperationException(Res.GetString("XmlInvalidSchemaElementType", new object[] { name.Name, name.Namespace, element.Name })); } if (!element.SubstitutionGroup.IsEmpty) { XmlQualifiedName name2 = XmlSchemas.GetParentName(element); throw new InvalidOperationException(Res.GetString("XmlInvalidSubstitutionGroupUse", new object[] { name2.Name, name2.Namespace })); } XmlQualifiedName parentName = XmlSchemas.GetParentName(element); throw new InvalidOperationException(Res.GetString("XmlElementMissingType", new object[] { parentName.Name, parentName.Namespace, element.Name })); } Label_014F: mapping.ReferencedByElement = true; return(mapping); }
private static string GetSchemaItem(XmlSchemaObject o, string ns, string details) { if (o == null) { return(null); } while (o.Parent != null && !(o.Parent is XmlSchema)) { o = o.Parent; } if (ns == null || ns.Length == 0) { XmlSchemaObject tmp = o; while (tmp.Parent != null) { tmp = tmp.Parent; } if (tmp is XmlSchema) { ns = ((XmlSchema)tmp).TargetNamespace; } } string item = null; if (o is XmlSchemaNotation) { item = SR.Format(SR.XmlSchemaNamedItem, ns, "notation", ((XmlSchemaNotation)o).Name, details); } else if (o is XmlSchemaGroup) { item = SR.Format(SR.XmlSchemaNamedItem, ns, "group", ((XmlSchemaGroup)o).Name, details); } else if (o is XmlSchemaElement) { XmlSchemaElement e = ((XmlSchemaElement)o); if (e.Name == null || e.Name.Length == 0) { XmlQualifiedName parentName = XmlSchemas.GetParentName(o); // Element reference '{0}' declared in schema type '{1}' from namespace '{2}' item = SR.Format(SR.XmlSchemaElementReference, e.RefName.ToString(), parentName.Name, parentName.Namespace); } else { item = SR.Format(SR.XmlSchemaNamedItem, ns, "element", e.Name, details); } } else if (o is XmlSchemaType) { item = SR.Format(SR.XmlSchemaNamedItem, ns, o.GetType() == typeof(XmlSchemaSimpleType) ? "simpleType" : "complexType", ((XmlSchemaType)o).Name, null); } else if (o is XmlSchemaAttributeGroup) { item = SR.Format(SR.XmlSchemaNamedItem, ns, "attributeGroup", ((XmlSchemaAttributeGroup)o).Name, details); } else if (o is XmlSchemaAttribute) { XmlSchemaAttribute a = ((XmlSchemaAttribute)o); if (a.Name == null || a.Name.Length == 0) { XmlQualifiedName parentName = XmlSchemas.GetParentName(o); // Attribure reference '{0}' declared in schema type '{1}' from namespace '{2}' return(SR.Format(SR.XmlSchemaAttributeReference, a.RefName.ToString(), parentName.Name, parentName.Namespace)); } else { item = SR.Format(SR.XmlSchemaNamedItem, ns, "attribute", a.Name, details); } } else if (o is XmlSchemaContent) { XmlQualifiedName parentName = XmlSchemas.GetParentName(o); // Check content definition of schema type '{0}' from namespace '{1}'. {2} item = SR.Format(SR.XmlSchemaContentDef, parentName.Name, parentName.Namespace, null); } else if (o is XmlSchemaExternal) { string itemType = o is XmlSchemaImport ? "import" : o is XmlSchemaInclude ? "include" : o is XmlSchemaRedefine ? "redefine" : o.GetType().Name; item = SR.Format(SR.XmlSchemaItem, ns, itemType, details); } else if (o is XmlSchema) { item = SR.Format(SR.XmlSchema, ns, details); } else { item = SR.Format(SR.XmlSchemaNamedItem, ns, o.GetType().Name, null, details); } return(item); }
private StructMapping ImportStructType(XmlSchemaComplexType type, string typeNs, bool excludeFromImport) { if (type.Name == null) { XmlSchemaElement element = (XmlSchemaElement)type.Parent; XmlQualifiedName parentType = XmlSchemas.GetParentName(element); throw new InvalidOperationException(SR.Format(SR.XmlInvalidSchemaElementType, parentType.Name, parentType.Namespace, element.Name)); } TypeDesc baseTypeDesc = null; Mapping baseMapping = null; if (!type.DerivedFrom.IsEmpty) { baseMapping = ImportType(type.DerivedFrom, excludeFromImport); if (baseMapping is StructMapping) { baseTypeDesc = ((StructMapping)baseMapping).TypeDesc; } else { baseMapping = null; } } if (baseMapping == null) { baseMapping = GetRootMapping(); } Mapping previousMapping = (Mapping)ImportedMappings[type]; if (previousMapping != null) { return((StructMapping)previousMapping); } string typeName = GenerateUniqueTypeName(Accessor.UnescapeName(type.Name)); StructMapping structMapping = new StructMapping(); structMapping.IsReference = Schemas.IsReference(type); TypeFlags flags = TypeFlags.Reference; if (type.IsAbstract) { flags |= TypeFlags.Abstract; } structMapping.TypeDesc = new TypeDesc(typeName, typeName, TypeKind.Struct, baseTypeDesc, flags); structMapping.Namespace = typeNs; structMapping.TypeName = type.Name; structMapping.BaseMapping = (StructMapping)baseMapping; ImportedMappings.Add(type, structMapping); if (excludeFromImport) { structMapping.IncludeInSchema = false; } CodeIdentifiers members = new CodeIdentifiers(); members.AddReserved(typeName); AddReservedIdentifiersForDataBinding(members); structMapping.Members = ImportTypeMembers(type, typeNs, members); Scope.AddTypeMapping(structMapping); ImportDerivedTypes(new XmlQualifiedName(type.Name, typeNs)); return(structMapping); }
private StructMapping ImportStructType(XmlSchemaComplexType type, string typeNs, bool excludeFromImport) { if (type.Name == null) { XmlSchemaElement parent = (XmlSchemaElement)type.Parent; XmlQualifiedName parentName = XmlSchemas.GetParentName(parent); throw new InvalidOperationException(Res.GetString("XmlInvalidSchemaElementType", new object[] { parentName.Name, parentName.Namespace, parent.Name })); } TypeDesc baseTypeDesc = null; Mapping rootMapping = null; if (!type.DerivedFrom.IsEmpty) { rootMapping = this.ImportType(type.DerivedFrom, excludeFromImport); if (rootMapping is StructMapping) { baseTypeDesc = ((StructMapping)rootMapping).TypeDesc; } else { rootMapping = null; } } if (rootMapping == null) { rootMapping = base.GetRootMapping(); } Mapping mapping2 = (Mapping)base.ImportedMappings[type]; if (mapping2 != null) { return((StructMapping)mapping2); } string str = base.GenerateUniqueTypeName(Accessor.UnescapeName(type.Name)); StructMapping mapping3 = new StructMapping { IsReference = base.Schemas.IsReference(type) }; TypeFlags reference = TypeFlags.Reference; if (type.IsAbstract) { reference |= TypeFlags.Abstract; } mapping3.TypeDesc = new TypeDesc(str, str, TypeKind.Struct, baseTypeDesc, reference); mapping3.Namespace = typeNs; mapping3.TypeName = type.Name; mapping3.BaseMapping = (StructMapping)rootMapping; base.ImportedMappings.Add(type, mapping3); if (excludeFromImport) { mapping3.IncludeInSchema = false; } CodeIdentifiers scope = new CodeIdentifiers(); scope.AddReserved(str); base.AddReservedIdentifiersForDataBinding(scope); mapping3.Members = this.ImportTypeMembers(type, typeNs, scope); base.Scope.AddTypeMapping(mapping3); this.ImportDerivedTypes(new XmlQualifiedName(type.Name, typeNs)); return(mapping3); }