static void AddProperty(ICctsProperty property, XmlSchemaSequence propertiesSequence, GeneratorContext context, XmlSchema schema, List <ICctsProperty> processedProperties) { var elementProperty = CreatePropertyElement(property, context, schema); if (property.otherPropertiesInChoice.Any()) { var choiceElement = new XmlSchemaChoice(); choiceElement.Items.Add(elementProperty); bool isOptional = property.LowerBound == "0"; foreach (var otherProperty in property.otherPropertiesInChoice) { if (!isOptional) { isOptional = otherProperty.LowerBound == "0"; } choiceElement.Items.Add(CreatePropertyElement(otherProperty, context, schema)); processedProperties.Add(otherProperty); } //set minoccurs to 0 is the choice is optional if (isOptional) { choiceElement.MinOccurs = 0; } //add the choice tot the sequence propertiesSequence.Items.Add(choiceElement); } else { // add the element created to the sequence propertiesSequence.Items.Add(elementProperty); } // add the property to the list of processed properties processedProperties.Add(property); }
static XmlSchemaElement CreatePropertyElement(ICctsProperty property, GeneratorContext context, XmlSchema schema) { if (property is IBbie) { return(CreateBbieSchemaElement((IBbie)property, context)); } if (property is IAsbie) { return(CreateAsbieSchemaElement((IAsbie)property, context, schema)); } throw new ArgumentException("Invalid type of argument property. Expected IBbie or IAsbie"); }