//============================================================
        //	ICOMPARABLE IMPLEMENTATION
        //============================================================
        #region CompareTo(object obj)
        /// <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 target is a null reference, instance is greater
            //------------------------------------------------------------
            if (obj == null)
            {
                return(1);
            }

            //------------------------------------------------------------
            //	Determine comparison result using property state of objects
            //------------------------------------------------------------
            SimpleListSyndicationExtension value = obj as SimpleListSyndicationExtension;

            if (value != null)
            {
                int result = this.Context.TreatAsList.CompareTo(value.Context.TreatAsList);
                result = result | SimpleListSyndicationExtension.CompareSequence(this.Context.Grouping, value.Context.Grouping);
                result = result | SimpleListSyndicationExtension.CompareSequence(this.Context.Sorting, value.Context.Sorting);

                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");
            }
        }
Example #2
0
        /// <summary>
        /// Saves the current <see cref="SimpleListGroup"/> 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
            //------------------------------------------------------------
            SimpleListSyndicationExtension extension = new SimpleListSyndicationExtension();

            //------------------------------------------------------------
            //	Write XML representation of the current instance
            //------------------------------------------------------------
            writer.WriteStartElement("group", extension.XmlNamespace);

            if (this.Namespace != null)
            {
                writer.WriteAttributeString("ns", this.Namespace.ToString());
            }

            if (!String.IsNullOrEmpty(this.Element))
            {
                writer.WriteAttributeString("element", this.Element);
            }

            if (!String.IsNullOrEmpty(this.Label))
            {
                writer.WriteAttributeString("label", this.Label);
            }

            writer.WriteEndElement();
        }
        /// <summary>
        /// Saves the current <see cref="SimpleListSort"/> 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");
            SimpleListSyndicationExtension extension = new SimpleListSyndicationExtension();

            writer.WriteStartElement("sort", extension.XmlNamespace);

            if (this.Namespace != null)
            {
                writer.WriteAttributeString("ns", this.Namespace.ToString());
            }

            if (!String.IsNullOrEmpty(this.Element))
            {
                writer.WriteAttributeString("element", this.Element);
            }

            if (!String.IsNullOrEmpty(this.Label))
            {
                writer.WriteAttributeString("label", this.Label);
            }

            if (this.DataType != SimpleListDataType.None)
            {
                writer.WriteAttributeString("data-type", SimpleListSort.DataTypeAsString(this.DataType));
            }

            if (this.IsDefault)
            {
                writer.WriteAttributeString("default", "true");
            }

            writer.WriteEndElement();
        }
        /// <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);
            }
            SimpleListSyndicationExtension value = obj as SimpleListSyndicationExtension;

            if (value != null)
            {
                int result = this.Context.TreatAsList.CompareTo(value.Context.TreatAsList);
                result = result | SimpleListSyndicationExtension.CompareSequence(this.Context.Grouping, value.Context.Grouping);
                result = result | SimpleListSyndicationExtension.CompareSequence(this.Context.Sorting, value.Context.Sorting);

                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="SimpleListGroup"/> 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");
            SimpleListSyndicationExtension extension = new SimpleListSyndicationExtension();

            writer.WriteStartElement("group", extension.XmlNamespace);

            if (this.Namespace != null)
            {
                writer.WriteAttributeString("ns", this.Namespace.ToString());
            }

            if (!String.IsNullOrEmpty(this.Element))
            {
                writer.WriteAttributeString("element", this.Element);
            }

            if (!String.IsNullOrEmpty(this.Label))
            {
                writer.WriteAttributeString("label", this.Label);
            }

            writer.WriteEndElement();
        }
Example #6
0
        /// <summary>
        /// Saves the current <see cref="SimpleListSort"/> 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
            //------------------------------------------------------------
            SimpleListSyndicationExtension extension    = new SimpleListSyndicationExtension();

            //------------------------------------------------------------
            //	Write XML representation of the current instance
            //------------------------------------------------------------
            writer.WriteStartElement("sort", extension.XmlNamespace);

            if(this.Namespace != null)
            {
                writer.WriteAttributeString("ns", this.Namespace.ToString());
            }

            if(!String.IsNullOrEmpty(this.Element))
            {
                writer.WriteAttributeString("element", this.Element);
            }

            if (!String.IsNullOrEmpty(this.Label))
            {
                writer.WriteAttributeString("label", this.Label);
            }

            if (this.DataType != SimpleListDataType.None)
            {
                writer.WriteAttributeString("data-type", SimpleListSort.DataTypeAsString(this.DataType));
            }

            if(this.IsDefault)
            {
                writer.WriteAttributeString("default", "true");
            }

            writer.WriteEndElement();
        }