Exemple #1
0
        /// <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);
            }
            AtomPublishingEditedSyndicationExtension value = obj as AtomPublishingEditedSyndicationExtension;

            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);

                result = result | this.Context.EditedOn.CompareTo(value.Context.EditedOn);

                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");
            }
        }
Exemple #2
0
        /// <summary>
        /// Saves the syndication resource to the specified <see cref="XmlWriter"/> and <see cref="SyndicationResourceSaveSettings"/>.
        /// </summary>
        /// <param name="writer">The <b>XmlWriter</b> to which you want to save the syndication resource.</param>
        /// <param name="settings">The <see cref="SyndicationResourceSaveSettings"/> object used to configure the persistance of the <see cref="AtomEntry"/> instance.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="writer"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="settings"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="XmlException">The operation would not result in well formed XML for the syndication resource.</exception>
        public new void Save(XmlWriter writer, SyndicationResourceSaveSettings settings)
        {
            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(writer, "writer");
            Guard.ArgumentNotNull(settings, "settings");

            //------------------------------------------------------------
            //	Modify syndication extensions based on properties
            //------------------------------------------------------------
            List<ISyndicationExtension> list    = new List<ISyndicationExtension>(this.Extensions);

            if(this.EditedOn != DateTime.MinValue)
            {
                if (!list.Exists(AtomPublishingEditedSyndicationExtension.MatchByType))
                {
                    AtomPublishingEditedSyndicationExtension editedExtension    = new AtomPublishingEditedSyndicationExtension();
                    editedExtension.Context.EditedOn                            = this.EditedOn;
                    this.AddExtension(editedExtension);
                }
            }

            if(this.IsDraft)
            {
                if (!list.Exists(AtomPublishingControlSyndicationExtension.MatchByType))
                {
                    AtomPublishingControlSyndicationExtension controlExtension  = new AtomPublishingControlSyndicationExtension();
                    controlExtension.Context.IsDraft                            = this.IsDraft;
                    this.AddExtension(controlExtension);
                }
            }

            //------------------------------------------------------------
            //	Save member resource
            //------------------------------------------------------------
            base.Save(writer, settings);
        }