System.Xml.Schema.XmlSchemaInference.SwitchUseToOptional C# (CSharp) Méthode

SwitchUseToOptional() private méthode

private SwitchUseToOptional ( XmlSchemaObjectCollection attributes, XmlSchemaObjectCollection attributesInInstance ) : void
attributes XmlSchemaObjectCollection
attributesInInstance XmlSchemaObjectCollection
Résultat void
            private void SwitchUseToOptional(XmlSchemaObjectCollection attributes, XmlSchemaObjectCollection attributesInInstance) {
                foreach (XmlSchemaObject attrObj in attributes) {
                    if (attrObj is XmlSchemaAttribute) {
                        XmlSchemaAttribute attr = attrObj as XmlSchemaAttribute;
                        if (attributesInInstance != null) {
                            if (attr.RefName.Name.Length == 0) { //If the attribute is not present in this instance, make it optional
                                if (null == FindAttribute(attributesInInstance, attr.Name)) {
                                    attr.Use = XmlSchemaUse.Optional;
                                }
                            }
                            else {
                                if (null == FindAttributeRef(attributesInInstance, attr.RefName.Name, attr.RefName.Namespace)) {
                                    attr.Use = XmlSchemaUse.Optional;
                                }
                            }
                        }
                        else {
                            attr.Use = XmlSchemaUse.Optional;
                        }
                    }
                }
            }