System.Xml.Schema.XmlSchemaComplexType.CloneAttributes C# (CSharp) Method

CloneAttributes() static private method

static private CloneAttributes ( XmlSchemaObjectCollection attributes ) : XmlSchemaObjectCollection
attributes XmlSchemaObjectCollection
return XmlSchemaObjectCollection
        internal static XmlSchemaObjectCollection CloneAttributes(XmlSchemaObjectCollection attributes) {
            if (HasAttributeQNameRef(attributes)) {
                XmlSchemaObjectCollection newAttributes = attributes.Clone();
                XmlSchemaAttributeGroupRef attributeGroupRef;
                XmlSchemaAttributeGroupRef newAttGroupRef;
                XmlSchemaObject xso;
                XmlSchemaAttribute att;

                for (int i = 0; i < attributes.Count; i++) {
                    xso = attributes[i];
                    attributeGroupRef = xso as XmlSchemaAttributeGroupRef;
                    if (attributeGroupRef != null) {
                        newAttGroupRef = (XmlSchemaAttributeGroupRef)attributeGroupRef.Clone();
                        newAttGroupRef.RefName = attributeGroupRef.RefName.Clone();
                        newAttributes[i] = newAttGroupRef;
                    }
                    else { //Its XmlSchemaAttribute
                        att = xso as XmlSchemaAttribute;
                        if (!att.RefName.IsEmpty || !att.SchemaTypeName.IsEmpty) {
                            newAttributes[i] = att.Clone();     
                        }
                    }
                }
                return newAttributes;
            }
            return attributes;
        }

Usage Example

        internal override XmlSchemaObject Clone()
        {
            XmlSchemaAttributeGroup group = (XmlSchemaAttributeGroup)base.MemberwiseClone();

            if (XmlSchemaComplexType.HasAttributeQNameRef(this.attributes))
            {
                group.attributes    = XmlSchemaComplexType.CloneAttributes(this.attributes);
                group.attributeUses = null;
            }
            return(group);
        }
All Usage Examples Of System.Xml.Schema.XmlSchemaComplexType::CloneAttributes