/// <summary> /// Declares 'field' members for a type. /// That is, all fields that apply to this type, either directly or through inheritance. /// </summary> /// <param name="entityType">The type entity.</param> private void AddTypeMembers(EffectiveType entityType, XmlSchema xsd) { // Example of member declaration // This contains both fields and relationships (and reverse relationships) //<xs:complexType name="type_person"> // <xs:all> // <!-- fields --> // <xs:element minOccurs="0" maxOccurs="1" ref="name" /> // <xs:element minOccurs="0" maxOccurs="1" ref="description" /> // <xs:element minOccurs="0" maxOccurs="1" ref="alias" /> // <xs:element minOccurs="0" maxOccurs="1" ref="firstName" /> // <xs:element minOccurs="0" maxOccurs="1" ref="lastName" /> // <!-- relationships --> // <xs:element minOccurs="0" maxOccurs="1" ref="worksFor" /> // </xs:all> //</xs:complexType> // Create a complex type, named "type_%typename%" var typeMembers = new XmlSchemaComplexType(); typeMembers.Name = NameDeclared("type_" + entityType.Alias.Value, entityType.Alias.Namespace); // Create a group to hold the members var memberGroup = new XmlSchemaAll(); typeMembers.Particle = memberGroup; // Add members AddTypeFields(entityType, memberGroup); AddTypeRelationships(entityType, memberGroup); // Add 'source' attribute for file types Entity file = _aliasResolver[Aliases2.File]; if (_schemaManager.IsSameOrDerivedType(entityType.Type, file)) { XmlSchemaAttribute sourceAttrib = new XmlSchemaAttribute(); sourceAttrib.Name = "source"; sourceAttrib.SchemaTypeName = XmlSchemaSimpleType.GetBuiltInSimpleType(XmlTypeCode.String).QualifiedName; typeMembers.Attributes.Add(sourceAttrib); } xsd.Items.Add(typeMembers); }