private void CopyOrOverrideAttributes(XmlWriter xmlWriter, IEnumerable <PropValue> propValueOverrides) { Dictionary <string, object> dictionary = new Dictionary <string, object>(); Util.AddRange <KeyValuePair <string, object>, KeyValuePair <string, object> >(dictionary, MasterCategoryListSerializer.PropValuesToAttributeNameValues(propValueOverrides)); while (this.xmlReader.MoveToNextAttribute()) { if (this.IsFromCategoriesNamespace()) { object value; if (dictionary.TryGetValue(this.xmlReader.LocalName, out value)) { dictionary.Remove(this.xmlReader.LocalName); MasterCategoryListSerializer.WriteAttributeForProperty(xmlWriter, this.xmlReader.LocalName, value); } else { xmlWriter.WriteAttributeString(this.xmlReader.LocalName, this.xmlReader.Value); } } else { xmlWriter.WriteAttributeString(this.xmlReader.Prefix, this.xmlReader.LocalName, this.xmlReader.NamespaceURI, this.xmlReader.Value); } } MasterCategoryListSerializer.WriteAttributesForProperties(xmlWriter, dictionary); this.xmlReader.MoveToElement(); }
internal static void Serialize(MasterCategoryList mcl, XmlWriter xmlWriter) { MasterCategoryListSerializer.CatchSerializationException(delegate { xmlWriter.WriteStartElement("categories", "CategoryList.xsd"); IEnumerable <PropValue> properties = MasterCategoryListSerializer.GetProperties(new MasterCategoryListSerializer.TryGetPropertyDelegate(mcl.TryGetProperty), MasterCategoryListSchema.Instance.AllProperties); MasterCategoryListSerializer.WriteAttributesForProperties(xmlWriter, MasterCategoryListSerializer.PropValuesToAttributeNameValues(properties)); MasterCategoryListSerializer.WriteCategoryElements(xmlWriter, mcl); xmlWriter.WriteEndElement(); }); }
private static void WriteCategoryElements(XmlWriter xmlWriter, IEnumerable <Category> categoriesToWrite) { string prefix = xmlWriter.LookupPrefix("CategoryList.xsd"); foreach (Category @object in categoriesToWrite) { xmlWriter.WriteStartElement(prefix, "category", "CategoryList.xsd"); IEnumerable <PropValue> properties = MasterCategoryListSerializer.GetProperties(new MasterCategoryListSerializer.TryGetPropertyDelegate(@object.TryGetProperty), CategorySchema.Instance.AllProperties); MasterCategoryListSerializer.WriteAttributesForProperties(xmlWriter, MasterCategoryListSerializer.PropValuesToAttributeNameValues(properties)); xmlWriter.WriteEndElement(); } }