/// <summary>
        /// Saves the current <see cref="LiveJournalSecurity"/> 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
            //------------------------------------------------------------
            LiveJournalSyndicationExtension extension = new LiveJournalSyndicationExtension();

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

            writer.WriteAttributeString("type", LiveJournalSecurity.AccessibilityAsString(this.Accessibility));

            if (this.Mask != Int32.MinValue)
            {
                writer.WriteAttributeString("mask", this.Mask.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
            }

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

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

            writer.WriteElementString("url", extension.XmlNamespace, this.Url != null ? this.Url.ToString() : String.Empty);
            writer.WriteElementString("keyword", extension.XmlNamespace, this.Keyword);
            writer.WriteElementString("width", extension.XmlNamespace, this.Width != Int32.MinValue ? this.Width.ToString(System.Globalization.NumberFormatInfo.InvariantInfo) : "0");
            writer.WriteElementString("height", extension.XmlNamespace, this.Height != Int32.MinValue ? this.Height.ToString(System.Globalization.NumberFormatInfo.InvariantInfo) : "0");

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

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

            if (this.Id != Int32.MinValue)
            {
                writer.WriteAttributeString("id", this.Id.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
            }

            writer.WriteCData(this.Content);

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

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

            writer.WriteAttributeString("type", LiveJournalSecurity.AccessibilityAsString(this.Accessibility));

            if (this.Mask != Int32.MinValue)
            {
                writer.WriteAttributeString("mask", this.Mask.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
            }

            writer.WriteEndElement();
        }
Esempio n. 5
0
        /// <summary>
        /// Saves the current <see cref="LiveJournalUserPicture"/> 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
            //------------------------------------------------------------
            LiveJournalSyndicationExtension extension = new LiveJournalSyndicationExtension();

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

            writer.WriteElementString("url", extension.XmlNamespace, this.Url != null ? this.Url.ToString() : String.Empty);
            writer.WriteElementString("keyword", extension.XmlNamespace, this.Keyword);
            writer.WriteElementString("width", extension.XmlNamespace, this.Width != Int32.MinValue ? this.Width.ToString(System.Globalization.NumberFormatInfo.InvariantInfo) : "0");
            writer.WriteElementString("height", extension.XmlNamespace, this.Height != Int32.MinValue ? this.Height.ToString(System.Globalization.NumberFormatInfo.InvariantInfo) : "0");

            writer.WriteEndElement();
        }
Esempio n. 6
0
        /// <summary>
        /// Saves the current <see cref="LiveJournalSecurity"/> 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
            //------------------------------------------------------------
            LiveJournalSyndicationExtension extension   = new LiveJournalSyndicationExtension();

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

            writer.WriteAttributeString("type", LiveJournalSecurity.AccessibilityAsString(this.Accessibility));

            if(this.Mask != Int32.MinValue)
            {
                writer.WriteAttributeString("mask", this.Mask.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
            }

            writer.WriteEndElement();
        }
Esempio n. 7
0
        /// <summary>
        /// Saves the current <see cref="LiveJournalUserPicture"/> 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
            //------------------------------------------------------------
            LiveJournalSyndicationExtension extension   = new LiveJournalSyndicationExtension();

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

            writer.WriteElementString("url", extension.XmlNamespace, this.Url != null ? this.Url.ToString() : String.Empty);
            writer.WriteElementString("keyword", extension.XmlNamespace, this.Keyword);
            writer.WriteElementString("width", extension.XmlNamespace, this.Width != Int32.MinValue ? this.Width.ToString(System.Globalization.NumberFormatInfo.InvariantInfo) : "0");
            writer.WriteElementString("height", extension.XmlNamespace, this.Height != Int32.MinValue ? this.Height.ToString(System.Globalization.NumberFormatInfo.InvariantInfo) : "0");

            writer.WriteEndElement();
        }
Esempio n. 8
0
        /// <summary>
        /// Loads this <see cref="LiveJournalUserPicture"/> 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="LiveJournalUserPicture"/> 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="LiveJournalUserPicture"/>.
        /// </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
            //------------------------------------------------------------
            LiveJournalSyndicationExtension extension   = new LiveJournalSyndicationExtension();
            XmlNamespaceManager manager                 = extension.CreateNamespaceManager(source);

            //------------------------------------------------------------
            //	Attempt to extract syndication information
            //------------------------------------------------------------
            if(source.HasChildren)
            {
                XPathNavigator urlNavigator     = source.SelectSingleNode("url", manager);
                XPathNavigator keywordNavigator = source.SelectSingleNode("keyword", manager);
                XPathNavigator widthNavigator   = source.SelectSingleNode("width", manager);
                XPathNavigator heightNavigator  = source.SelectSingleNode("height", manager);

                if (urlNavigator != null)
                {
                    Uri url;
                    if (Uri.TryCreate(urlNavigator.Value, UriKind.RelativeOrAbsolute, out url))
                    {
                        this.Url    = url;
                        wasLoaded   = true;
                    }
                }

                if (keywordNavigator != null && !String.IsNullOrEmpty(keywordNavigator.Value))
                {
                    this.Keyword    = keywordNavigator.Value;
                    wasLoaded       = true;
                }

                if (widthNavigator != null)
                {
                    int width;
                    if (Int32.TryParse(widthNavigator.Value, System.Globalization.NumberStyles.Integer, System.Globalization.NumberFormatInfo.InvariantInfo, out width))
                    {
                        if (width > 100)
                        {
                            width = 100;
                        }
                        this.Width  = width;
                        wasLoaded   = true;
                    }
                }

                if (heightNavigator != null)
                {
                    int height;
                    if (Int32.TryParse(heightNavigator.Value, System.Globalization.NumberStyles.Integer, System.Globalization.NumberFormatInfo.InvariantInfo, out height))
                    {
                        if (height > 100)
                        {
                            height = 100;
                        }
                        this.Height = height;
                        wasLoaded   = true;
                    }
                }
            }

            return wasLoaded;
        }
        //============================================================
        //	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
            //------------------------------------------------------------
            LiveJournalSyndicationExtension value = obj as LiveJournalSyndicationExtension;

            if (value != null)
            {
                int result = this.Context.IsPreformatted.CompareTo(value.Context.IsPreformatted);

                if (this.Context.Mood != null)
                {
                    if (value.Context.Mood != null)
                    {
                        result = result | this.Context.Mood.CompareTo(value.Context.Mood);
                    }
                    else
                    {
                        result = result | 1;
                    }
                }
                else if (this.Context.Mood == null && value.Context.Mood != null)
                {
                    result = result | -1;
                }

                result = result | String.Compare(this.Context.Music, value.Context.Music, StringComparison.OrdinalIgnoreCase);

                if (this.Context.Security != null)
                {
                    if (value.Context.Security != null)
                    {
                        result = result | this.Context.Security.CompareTo(value.Context.Security);
                    }
                    else
                    {
                        result = result | 1;
                    }
                }
                else if (this.Context.Security == null && value.Context.Security != null)
                {
                    result = result | -1;
                }

                if (this.Context.UserPicture != null)
                {
                    if (value.Context.UserPicture != null)
                    {
                        result = result | this.Context.UserPicture.CompareTo(value.Context.UserPicture);
                    }
                    else
                    {
                        result = result | 1;
                    }
                }
                else if (this.Context.UserPicture == null && value.Context.UserPicture != 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");
            }
        }
Esempio n. 10
0
        //============================================================
        //	PUBLIC METHODS
        //============================================================
        #region Load(XPathNavigator source)
        /// <summary>
        /// Loads this <see cref="LiveJournalUserPicture"/> 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="LiveJournalUserPicture"/> 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="LiveJournalUserPicture"/>.
        /// </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
            //------------------------------------------------------------
            LiveJournalSyndicationExtension extension = new LiveJournalSyndicationExtension();
            XmlNamespaceManager             manager   = extension.CreateNamespaceManager(source);

            //------------------------------------------------------------
            //	Attempt to extract syndication information
            //------------------------------------------------------------
            if (source.HasChildren)
            {
                XPathNavigator urlNavigator     = source.SelectSingleNode("url", manager);
                XPathNavigator keywordNavigator = source.SelectSingleNode("keyword", manager);
                XPathNavigator widthNavigator   = source.SelectSingleNode("width", manager);
                XPathNavigator heightNavigator  = source.SelectSingleNode("height", manager);

                if (urlNavigator != null)
                {
                    Uri url;
                    if (Uri.TryCreate(urlNavigator.Value, UriKind.RelativeOrAbsolute, out url))
                    {
                        this.Url  = url;
                        wasLoaded = true;
                    }
                }

                if (keywordNavigator != null && !String.IsNullOrEmpty(keywordNavigator.Value))
                {
                    this.Keyword = keywordNavigator.Value;
                    wasLoaded    = true;
                }

                if (widthNavigator != null)
                {
                    int width;
                    if (Int32.TryParse(widthNavigator.Value, System.Globalization.NumberStyles.Integer, System.Globalization.NumberFormatInfo.InvariantInfo, out width))
                    {
                        if (width > 100)
                        {
                            width = 100;
                        }
                        this.Width = width;
                        wasLoaded  = true;
                    }
                }

                if (heightNavigator != null)
                {
                    int height;
                    if (Int32.TryParse(heightNavigator.Value, System.Globalization.NumberStyles.Integer, System.Globalization.NumberFormatInfo.InvariantInfo, out height))
                    {
                        if (height > 100)
                        {
                            height = 100;
                        }
                        this.Height = height;
                        wasLoaded   = true;
                    }
                }
            }

            return(wasLoaded);
        }