/// <summary> /// Saves the current <see cref="FeedSynchronizationHistory"/> to the specified <see cref="XmlWriter"/>. /// </summary> /// <param name="writer">The <see cref="XmlWriter"/> to which you want to save.</param> /// <exception cref="ArgumentNullException">The <paramref name="writer"/> is a null reference (Nothing in Visual Basic).</exception> public void WriteTo(XmlWriter writer) { //------------------------------------------------------------ // Validate parameter //------------------------------------------------------------ Guard.ArgumentNotNull(writer, "writer"); //------------------------------------------------------------ // Create extension instance to retrieve XML namespace //------------------------------------------------------------ FeedSynchronizationSyndicationExtension extension = new FeedSynchronizationSyndicationExtension(); //------------------------------------------------------------ // Write XML representation of the current instance //------------------------------------------------------------ writer.WriteStartElement("history", extension.XmlNamespace); writer.WriteAttributeString("sequence", this.Sequence.ToString(System.Globalization.NumberFormatInfo.InvariantInfo)); if (this.When != DateTime.MinValue) { writer.WriteAttributeString("when", SyndicationDateTimeUtility.ToRfc3339DateTime(this.When)); } if (!String.IsNullOrEmpty(this.By)) { writer.WriteAttributeString("when", this.By); } writer.WriteEndElement(); }
/// <summary> /// Saves the current <see cref="FeedSynchronizationSharingInformation"/> to the specified <see cref="XmlWriter"/>. /// </summary> /// <param name="writer">The <see cref="XmlWriter"/> to which you want to save.</param> /// <exception cref="ArgumentNullException">The <paramref name="writer"/> is a null reference (Nothing in Visual Basic).</exception> public void WriteTo(XmlWriter writer) { Guard.ArgumentNotNull(writer, "writer"); FeedSynchronizationSyndicationExtension extension = new FeedSynchronizationSyndicationExtension(); writer.WriteStartElement("sharing", extension.XmlNamespace); if (!String.IsNullOrEmpty(this.Since)) { writer.WriteAttributeString("since", this.Since); } if (!String.IsNullOrEmpty(this.Until)) { writer.WriteAttributeString("until", this.Until); } if (this.ExpiresOn != DateTime.MinValue) { writer.WriteAttributeString("expires", SyndicationDateTimeUtility.ToRfc3339DateTime(this.ExpiresOn)); } foreach (FeedSynchronizationRelatedInformation relation in this.Relations) { relation.WriteTo(writer); } writer.WriteEndElement(); }
/// <summary> /// Saves the current <see cref="FeedSynchronizationRelatedInformation"/> to the specified <see cref="XmlWriter"/>. /// </summary> /// <param name="writer">The <see cref="XmlWriter"/> to which you want to save.</param> /// <exception cref="ArgumentNullException">The <paramref name="writer"/> is a null reference (Nothing in Visual Basic).</exception> public void WriteTo(XmlWriter writer) { //------------------------------------------------------------ // Validate parameter //------------------------------------------------------------ Guard.ArgumentNotNull(writer, "writer"); //------------------------------------------------------------ // Create extension instance to retrieve XML namespace //------------------------------------------------------------ FeedSynchronizationSyndicationExtension extension = new FeedSynchronizationSyndicationExtension(); //------------------------------------------------------------ // Write XML representation of the current instance //------------------------------------------------------------ writer.WriteStartElement("related", extension.XmlNamespace); writer.WriteAttributeString("link", extension.XmlNamespace, this.Link != null ? this.Link.ToString() : String.Empty); if (!String.IsNullOrEmpty(this.Title)) { writer.WriteAttributeString("title", extension.XmlNamespace, this.Title); } writer.WriteAttributeString("type", extension.XmlNamespace, FeedSynchronizationRelatedInformation.RelationTypeAsString(this.RelationType)); writer.WriteEndElement(); }
/// <summary> /// Loads this <see cref="FeedSynchronizationSharingInformation"/> using the supplied <see cref="XPathNavigator"/>. /// </summary> /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param> /// <returns><b>true</b> if the <see cref="FeedSynchronizationSharingInformation"/> was initialized using the supplied <paramref name="source"/>, otherwise <b>false</b>.</returns> /// <remarks> /// This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents a <see cref="FeedSynchronizationSharingInformation"/>. /// </remarks> /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception> public bool Load(XPathNavigator source) { bool wasLoaded = false; Guard.ArgumentNotNull(source, "source"); FeedSynchronizationSyndicationExtension extension = new FeedSynchronizationSyndicationExtension(); XmlNamespaceManager manager = extension.CreateNamespaceManager(source); if (source.HasAttributes) { string sinceAttribute = source.GetAttribute("since", String.Empty); string untilAttribute = source.GetAttribute("until", String.Empty); string expiresAttribute = source.GetAttribute("expires", String.Empty); if (!String.IsNullOrEmpty(sinceAttribute)) { this.Since = sinceAttribute; wasLoaded = true; } if (!String.IsNullOrEmpty(untilAttribute)) { this.Until = untilAttribute; wasLoaded = true; } if (!String.IsNullOrEmpty(expiresAttribute)) { DateTime expiresOn; if (SyndicationDateTimeUtility.TryParseRfc3339DateTime(expiresAttribute, out expiresOn)) { this.ExpiresOn = expiresOn; wasLoaded = true; } } } if (source.HasChildren) { XPathNodeIterator relatedIterator = source.Select("sx:related", manager); if (relatedIterator != null && relatedIterator.Count > 0) { while (relatedIterator.MoveNext()) { FeedSynchronizationRelatedInformation relation = new FeedSynchronizationRelatedInformation(); if (relation.Load(relatedIterator.Current)) { this.Relations.Add(relation); wasLoaded = true; } } } } return(wasLoaded); }
/// <summary> /// Compares the current instance with another object of the same type. /// </summary> /// <param name="obj">An object to compare with this instance.</param> /// <returns>A 32-bit signed integer that indicates the relative order of the objects being compared.</returns> /// <exception cref="ArgumentException">The <paramref name="obj"/> is not the expected <see cref="Type"/>.</exception> public int CompareTo(object obj) { if (obj == null) { return(1); } FeedSynchronizationSyndicationExtension value = obj as FeedSynchronizationSyndicationExtension; if (value != null) { int result = String.Compare(this.Description, value.Description, StringComparison.OrdinalIgnoreCase); result = result | Uri.Compare(this.Documentation, value.Documentation, UriComponents.AbsoluteUri, UriFormat.SafeUnescaped, StringComparison.OrdinalIgnoreCase); result = result | String.Compare(this.Name, value.Name, StringComparison.OrdinalIgnoreCase); result = result | this.Version.CompareTo(value.Version); result = result | String.Compare(this.XmlNamespace, value.XmlNamespace, StringComparison.Ordinal); result = result | String.Compare(this.XmlPrefix, value.XmlPrefix, StringComparison.Ordinal); if (this.Context.Sharing != null) { if (value.Context.Sharing != null) { result = result | this.Context.Sharing.CompareTo(value.Context.Sharing); } else { result = result | 1; } } else if (this.Context.Sharing == null && value.Context.Sharing != null) { result = result | -1; } if (this.Context.Synchronization != null) { if (value.Context.Synchronization != null) { result = result | this.Context.Synchronization.CompareTo(value.Context.Synchronization); } else { result = result | 1; } } else if (this.Context.Synchronization == null && value.Context.Synchronization != null) { result = result | -1; } return(result); } else { throw new ArgumentException(String.Format(null, "obj is not of type {0}, type was found to be '{1}'.", this.GetType().FullName, obj.GetType().FullName), "obj"); } }
/// <summary> /// Saves the current <see cref="FeedSynchronizationRelatedInformation"/> to the specified <see cref="XmlWriter"/>. /// </summary> /// <param name="writer">The <see cref="XmlWriter"/> to which you want to save.</param> /// <exception cref="ArgumentNullException">The <paramref name="writer"/> is a null reference (Nothing in Visual Basic).</exception> public void WriteTo(XmlWriter writer) { Guard.ArgumentNotNull(writer, "writer"); FeedSynchronizationSyndicationExtension extension = new FeedSynchronizationSyndicationExtension(); writer.WriteStartElement("related", extension.XmlNamespace); writer.WriteAttributeString("link", extension.XmlNamespace, this.Link != null ? this.Link.ToString() : String.Empty); if (!String.IsNullOrEmpty(this.Title)) { writer.WriteAttributeString("title", extension.XmlNamespace, this.Title); } writer.WriteAttributeString("type", extension.XmlNamespace, FeedSynchronizationRelatedInformation.RelationTypeAsString(this.RelationType)); writer.WriteEndElement(); }
/// <summary> /// Saves the current <see cref="FeedSynchronizationItem"/> to the specified <see cref="XmlWriter"/>. /// </summary> /// <param name="writer">The <see cref="XmlWriter"/> to which you want to save.</param> /// <exception cref="ArgumentNullException">The <paramref name="writer"/> is a null reference (Nothing in Visual Basic).</exception> public void WriteTo(XmlWriter writer) { //------------------------------------------------------------ // Validate parameter //------------------------------------------------------------ Guard.ArgumentNotNull(writer, "writer"); //------------------------------------------------------------ // Create extension instance to retrieve XML namespace //------------------------------------------------------------ FeedSynchronizationSyndicationExtension extension = new FeedSynchronizationSyndicationExtension(); //------------------------------------------------------------ // Write XML representation of the current instance //------------------------------------------------------------ writer.WriteStartElement("sync", extension.XmlNamespace); writer.WriteAttributeString("id", this.Id); writer.WriteAttributeString("updates", this.Updates.ToString(NumberFormatInfo.InvariantInfo)); if (this.TombstoneStatus != FeedSynchronizationTombstoneStatus.None) { writer.WriteAttributeString("deleted", FeedSynchronizationItem.TombstoneStatusAsString(this.TombstoneStatus)); } if (this.ConflictPreservation != FeedSynchronizationConflictPreservationDirective.None) { writer.WriteAttributeString("noconflicts", FeedSynchronizationItem.ConflictPreservationAsString(this.ConflictPreservation)); } foreach (FeedSynchronizationHistory history in this.Histories) { history.WriteTo(writer); } if (this.Conflicts.Count > 0) { writer.WriteStartElement("conflicts", extension.XmlNamespace); foreach (XPathNavigator conflict in this.Conflicts) { conflict.WriteSubtree(writer); } writer.WriteEndElement(); } writer.WriteEndElement(); }
/// <summary> /// Saves the current <see cref="FeedSynchronizationHistory"/> to the specified <see cref="XmlWriter"/>. /// </summary> /// <param name="writer">The <see cref="XmlWriter"/> to which you want to save.</param> /// <exception cref="ArgumentNullException">The <paramref name="writer"/> is a null reference (Nothing in Visual Basic).</exception> public void WriteTo(XmlWriter writer) { Guard.ArgumentNotNull(writer, "writer"); FeedSynchronizationSyndicationExtension extension = new FeedSynchronizationSyndicationExtension(); writer.WriteStartElement("history", extension.XmlNamespace); writer.WriteAttributeString("sequence", this.Sequence.ToString(System.Globalization.NumberFormatInfo.InvariantInfo)); if (this.When != DateTime.MinValue) { writer.WriteAttributeString("when", SyndicationDateTimeUtility.ToRfc3339DateTime(this.When)); } if (!String.IsNullOrEmpty(this.By)) { writer.WriteAttributeString("when", this.By); } writer.WriteEndElement(); }
/// <summary> /// Saves the current <see cref="FeedSynchronizationSharingInformation"/> to the specified <see cref="XmlWriter"/>. /// </summary> /// <param name="writer">The <see cref="XmlWriter"/> to which you want to save.</param> /// <exception cref="ArgumentNullException">The <paramref name="writer"/> is a null reference (Nothing in Visual Basic).</exception> public void WriteTo(XmlWriter writer) { //------------------------------------------------------------ // Validate parameter //------------------------------------------------------------ Guard.ArgumentNotNull(writer, "writer"); //------------------------------------------------------------ // Create extension instance to retrieve XML namespace //------------------------------------------------------------ FeedSynchronizationSyndicationExtension extension = new FeedSynchronizationSyndicationExtension(); //------------------------------------------------------------ // Write XML representation of the current instance //------------------------------------------------------------ writer.WriteStartElement("sharing", extension.XmlNamespace); if (!String.IsNullOrEmpty(this.Since)) { writer.WriteAttributeString("since", this.Since); } if (!String.IsNullOrEmpty(this.Until)) { writer.WriteAttributeString("until", this.Until); } if (this.ExpiresOn != DateTime.MinValue) { writer.WriteAttributeString("expires", SyndicationDateTimeUtility.ToRfc3339DateTime(this.ExpiresOn)); } foreach (FeedSynchronizationRelatedInformation relation in this.Relations) { relation.WriteTo(writer); } writer.WriteEndElement(); }
//============================================================ // PUBLIC METHODS //============================================================ #region Load(XPathNavigator source) /// <summary> /// Loads this <see cref="FeedSynchronizationItem"/> using the supplied <see cref="XPathNavigator"/>. /// </summary> /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param> /// <returns><b>true</b> if the <see cref="FeedSynchronizationItem"/> was initialized using the supplied <paramref name="source"/>, otherwise <b>false</b>.</returns> /// <remarks> /// This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents a <see cref="FeedSynchronizationItem"/>. /// </remarks> /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception> public bool Load(XPathNavigator source) { //------------------------------------------------------------ // Local members //------------------------------------------------------------ bool wasLoaded = false; //------------------------------------------------------------ // Validate parameter //------------------------------------------------------------ Guard.ArgumentNotNull(source, "source"); //------------------------------------------------------------ // Create namespace manager to resolve prefixed elements //------------------------------------------------------------ FeedSynchronizationSyndicationExtension extension = new FeedSynchronizationSyndicationExtension(); XmlNamespaceManager manager = extension.CreateNamespaceManager(source); //------------------------------------------------------------ // Attempt to extract syndication information //------------------------------------------------------------ if (source.HasAttributes) { string idAttribute = source.GetAttribute("id", String.Empty); string updatesAttribute = source.GetAttribute("updates", String.Empty); string deletedAttribute = source.GetAttribute("deleted", String.Empty); string noConflictsAttribute = source.GetAttribute("noconflicts", String.Empty); if (!String.IsNullOrEmpty(idAttribute)) { this.Id = idAttribute; wasLoaded = true; } if (!String.IsNullOrEmpty(updatesAttribute)) { int updates; if (Int32.TryParse(updatesAttribute, NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out updates)) { this.Updates = updates; wasLoaded = true; } } if (!String.IsNullOrEmpty(deletedAttribute)) { FeedSynchronizationTombstoneStatus status = FeedSynchronizationItem.TombstoneStatusByName(deletedAttribute); if (status != FeedSynchronizationTombstoneStatus.None) { this.TombstoneStatus = status; wasLoaded = true; } } if (!String.IsNullOrEmpty(noConflictsAttribute)) { FeedSynchronizationConflictPreservationDirective directive = FeedSynchronizationItem.ConflictPreservationByName(noConflictsAttribute); if (directive != FeedSynchronizationConflictPreservationDirective.None) { this.ConflictPreservation = directive; wasLoaded = true; } } } if (source.HasChildren) { XPathNodeIterator historyIterator = source.Select("sx:history", manager); XPathNavigator conflictsNavigator = source.SelectSingleNode("sx:conflicts", manager); if (historyIterator != null && historyIterator.Count > 0) { while (historyIterator.MoveNext()) { FeedSynchronizationHistory history = new FeedSynchronizationHistory(); if (history.Load(historyIterator.Current)) { this.Histories.Add(history); wasLoaded = true; } } } if (conflictsNavigator != null && conflictsNavigator.HasChildren) { XPathNodeIterator childrenIterator = conflictsNavigator.SelectChildren(XPathNodeType.Element); if (childrenIterator != null && childrenIterator.Count > 0) { this.Conflicts.Add(childrenIterator.Current); wasLoaded = true; } } } return(wasLoaded); }
/// <summary> /// Saves the current <see cref="FeedSynchronizationHistory"/> to the specified <see cref="XmlWriter"/>. /// </summary> /// <param name="writer">The <see cref="XmlWriter"/> to which you want to save.</param> /// <exception cref="ArgumentNullException">The <paramref name="writer"/> is a null reference (Nothing in Visual Basic).</exception> public void WriteTo(XmlWriter writer) { //------------------------------------------------------------ // Validate parameter //------------------------------------------------------------ Guard.ArgumentNotNull(writer, "writer"); //------------------------------------------------------------ // Create extension instance to retrieve XML namespace //------------------------------------------------------------ FeedSynchronizationSyndicationExtension extension = new FeedSynchronizationSyndicationExtension(); //------------------------------------------------------------ // Write XML representation of the current instance //------------------------------------------------------------ writer.WriteStartElement("history", extension.XmlNamespace); writer.WriteAttributeString("sequence", this.Sequence.ToString(System.Globalization.NumberFormatInfo.InvariantInfo)); if(this.When != DateTime.MinValue) { writer.WriteAttributeString("when", SyndicationDateTimeUtility.ToRfc3339DateTime(this.When)); } if(!String.IsNullOrEmpty(this.By)) { writer.WriteAttributeString("when", this.By); } writer.WriteEndElement(); }
/// <summary> /// Saves the current <see cref="FeedSynchronizationSharingInformation"/> to the specified <see cref="XmlWriter"/>. /// </summary> /// <param name="writer">The <see cref="XmlWriter"/> to which you want to save.</param> /// <exception cref="ArgumentNullException">The <paramref name="writer"/> is a null reference (Nothing in Visual Basic).</exception> public void WriteTo(XmlWriter writer) { //------------------------------------------------------------ // Validate parameter //------------------------------------------------------------ Guard.ArgumentNotNull(writer, "writer"); //------------------------------------------------------------ // Create extension instance to retrieve XML namespace //------------------------------------------------------------ FeedSynchronizationSyndicationExtension extension = new FeedSynchronizationSyndicationExtension(); //------------------------------------------------------------ // Write XML representation of the current instance //------------------------------------------------------------ writer.WriteStartElement("sharing", extension.XmlNamespace); if(!String.IsNullOrEmpty(this.Since)) { writer.WriteAttributeString("since", this.Since); } if (!String.IsNullOrEmpty(this.Until)) { writer.WriteAttributeString("until", this.Until); } if(this.ExpiresOn != DateTime.MinValue) { writer.WriteAttributeString("expires", SyndicationDateTimeUtility.ToRfc3339DateTime(this.ExpiresOn)); } foreach(FeedSynchronizationRelatedInformation relation in this.Relations) { relation.WriteTo(writer); } writer.WriteEndElement(); }
/// <summary> /// Loads this <see cref="FeedSynchronizationSharingInformation"/> using the supplied <see cref="XPathNavigator"/>. /// </summary> /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param> /// <returns><b>true</b> if the <see cref="FeedSynchronizationSharingInformation"/> was initialized using the supplied <paramref name="source"/>, otherwise <b>false</b>.</returns> /// <remarks> /// This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents a <see cref="FeedSynchronizationSharingInformation"/>. /// </remarks> /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception> public bool Load(XPathNavigator source) { //------------------------------------------------------------ // Local members //------------------------------------------------------------ bool wasLoaded = false; //------------------------------------------------------------ // Validate parameter //------------------------------------------------------------ Guard.ArgumentNotNull(source, "source"); //------------------------------------------------------------ // Create namespace manager to resolve prefixed elements //------------------------------------------------------------ FeedSynchronizationSyndicationExtension extension = new FeedSynchronizationSyndicationExtension(); XmlNamespaceManager manager = extension.CreateNamespaceManager(source); //------------------------------------------------------------ // Attempt to extract syndication information //------------------------------------------------------------ if (source.HasAttributes) { string sinceAttribute = source.GetAttribute("since", String.Empty); string untilAttribute = source.GetAttribute("until", String.Empty); string expiresAttribute = source.GetAttribute("expires", String.Empty); if (!String.IsNullOrEmpty(sinceAttribute)) { this.Since = sinceAttribute; wasLoaded = true; } if (!String.IsNullOrEmpty(untilAttribute)) { this.Until = untilAttribute; wasLoaded = true; } if (!String.IsNullOrEmpty(expiresAttribute)) { DateTime expiresOn; if (SyndicationDateTimeUtility.TryParseRfc3339DateTime(expiresAttribute, out expiresOn)) { this.ExpiresOn = expiresOn; wasLoaded = true; } } } if (source.HasChildren) { XPathNodeIterator relatedIterator = source.Select("sx:related", manager); if (relatedIterator != null && relatedIterator.Count > 0) { while (relatedIterator.MoveNext()) { FeedSynchronizationRelatedInformation relation = new FeedSynchronizationRelatedInformation(); if (relation.Load(relatedIterator.Current)) { this.Relations.Add(relation); wasLoaded = true; } } } } return wasLoaded; }
/// <summary> /// Saves the current <see cref="FeedSynchronizationRelatedInformation"/> to the specified <see cref="XmlWriter"/>. /// </summary> /// <param name="writer">The <see cref="XmlWriter"/> to which you want to save.</param> /// <exception cref="ArgumentNullException">The <paramref name="writer"/> is a null reference (Nothing in Visual Basic).</exception> public void WriteTo(XmlWriter writer) { //------------------------------------------------------------ // Validate parameter //------------------------------------------------------------ Guard.ArgumentNotNull(writer, "writer"); //------------------------------------------------------------ // Create extension instance to retrieve XML namespace //------------------------------------------------------------ FeedSynchronizationSyndicationExtension extension = new FeedSynchronizationSyndicationExtension(); //------------------------------------------------------------ // Write XML representation of the current instance //------------------------------------------------------------ writer.WriteStartElement("related", extension.XmlNamespace); writer.WriteAttributeString("link", extension.XmlNamespace, this.Link != null ? this.Link.ToString() : String.Empty); if(!String.IsNullOrEmpty(this.Title)) { writer.WriteAttributeString("title", extension.XmlNamespace, this.Title); } writer.WriteAttributeString("type", extension.XmlNamespace, FeedSynchronizationRelatedInformation.RelationTypeAsString(this.RelationType)); writer.WriteEndElement(); }