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

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

            writer.WriteElementString("format", extension.XmlNamespace, this.Format != null ? this.Format.ToString() : String.Empty);

            if (this.Encoding != null)
            {
                writer.WriteElementString("encoding", extension.XmlNamespace, this.Encoding.ToString());
            }

            writer.WriteCData(this.Content);

            writer.WriteEndElement();
        }
예제 #2
0
        //============================================================
        //	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
            //------------------------------------------------------------
            SiteSummaryContentSyndicationExtension value = obj as SiteSummaryContentSyndicationExtension;

            if (value != null)
            {
                int result = String.Compare(this.Context.Encoded, value.Context.Encoded, StringComparison.Ordinal);
                result = result | SiteSummaryContentSyndicationExtension.CompareSequence(this.Context.Items, value.Context.Items);

                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");
            }
        }
        //============================================================
        //	PUBLIC METHODS
        //============================================================
        #region Load(XPathNavigator source)
        /// <summary>
        /// Loads this <see cref="SiteSummaryContentItem"/> 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="SiteSummaryContentItem"/> 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="SiteSummaryContentItem"/>.
        /// </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
            //------------------------------------------------------------
            SiteSummaryContentSyndicationExtension extension = new SiteSummaryContentSyndicationExtension();
            XmlNamespaceManager manager = extension.CreateNamespaceManager(source);

            //------------------------------------------------------------
            //	Attempt to extract syndication information
            //------------------------------------------------------------
            if (source.HasChildren)
            {
                XPathNavigator formatNavigator   = source.SelectSingleNode("content:format", manager);
                XPathNavigator encodingNavigator = source.SelectSingleNode("content:encoding", manager);

                if (formatNavigator != null)
                {
                    Uri format;
                    if (Uri.TryCreate(formatNavigator.Value, UriKind.RelativeOrAbsolute, out format))
                    {
                        this.Format = format;
                        wasLoaded   = true;
                    }
                }

                if (encodingNavigator != null)
                {
                    Uri encoding;
                    if (Uri.TryCreate(encodingNavigator.Value, UriKind.RelativeOrAbsolute, out encoding))
                    {
                        this.Encoding = encoding;
                        wasLoaded     = true;
                    }
                }
            }

            if (!String.IsNullOrEmpty(source.Value))
            {
                this.Content = source.Value;
                wasLoaded    = true;
            }

            return(wasLoaded);
        }
        /// <summary>
        /// Saves the current <see cref="SiteSummaryContentItem"/> 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");
            SiteSummaryContentSyndicationExtension extension = new SiteSummaryContentSyndicationExtension();

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

            writer.WriteElementString("format", extension.XmlNamespace, this.Format != null ? this.Format.ToString() : String.Empty);

            if (this.Encoding != null)
            {
                writer.WriteElementString("encoding", extension.XmlNamespace, this.Encoding.ToString());
            }

            writer.WriteCData(this.Content);

            writer.WriteEndElement();
        }
        /// <summary>
        /// Loads this <see cref="SiteSummaryContentItem"/> 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="SiteSummaryContentItem"/> 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="SiteSummaryContentItem"/>.
        /// </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");
            SiteSummaryContentSyndicationExtension extension = new SiteSummaryContentSyndicationExtension();
            XmlNamespaceManager manager = extension.CreateNamespaceManager(source);

            if (source.HasChildren)
            {
                XPathNavigator formatNavigator   = source.SelectSingleNode("content:format", manager);
                XPathNavigator encodingNavigator = source.SelectSingleNode("content:encoding", manager);

                if (formatNavigator != null)
                {
                    Uri format;
                    if (Uri.TryCreate(formatNavigator.Value, UriKind.RelativeOrAbsolute, out format))
                    {
                        this.Format = format;
                        wasLoaded   = true;
                    }
                }

                if (encodingNavigator != null)
                {
                    Uri encoding;
                    if (Uri.TryCreate(encodingNavigator.Value, UriKind.RelativeOrAbsolute, out encoding))
                    {
                        this.Encoding = encoding;
                        wasLoaded     = true;
                    }
                }
            }

            if (!String.IsNullOrEmpty(source.Value))
            {
                this.Content = source.Value;
                wasLoaded    = true;
            }

            return(wasLoaded);
        }
예제 #6
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);
            }
            SiteSummaryContentSyndicationExtension value = obj as SiteSummaryContentSyndicationExtension;

            if (value != null)
            {
                int result = String.Compare(this.Context.Encoded, value.Context.Encoded, StringComparison.Ordinal);
                result = result | SiteSummaryContentSyndicationExtension.CompareSequence(this.Context.Items, value.Context.Items);

                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");
            }
        }
예제 #7
0
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        RssFeed feed = new RssFeed();

        feed.Channel.Link = new Uri("http://blag.Jiyuu.org/");
        feed.Channel.Title = "אנימה בלאג";
        feed.Channel.Description = "סיכום הפוסטים האחרונים שאונדקסו בבלאג";

        List<BlogPost> posts = AggregationManager.GetPosts(null, null).Take(15).ToList();

        RssItem item;
        foreach (BlogPost post in posts)
        {
            item = new RssItem();
            item.Title = post.Title;
            item.Link = new Uri(post.Link);
            item.Description = post.Summary;

            Argotic.Extensions.Core.SiteSummaryContentSyndicationExtension contentExt = new Argotic.Extensions.Core.SiteSummaryContentSyndicationExtension();
            contentExt.Context.Encoded = "";// HttpUtility.HtmlDecode(string.Format(@"<dir=""rtl"" style=""text-align: right;"" trbidi=""on"">{0}</div>", post.Summary));
            //Argotic.Extensions.Core.SiteSummaryContentItem content = new Argotic.Extensions.Core.SiteSummaryContentItem();
            //content.Content = new XCData(string.Format(@"<dir=""rtl"" style=""text-align: right;"" trbidi=""on"">{0}</div>", post.Summary)).ToString();
            //contentExt.Context.Items.Add(content);
            item.AddExtension(contentExt);
            item.PublicationDate = post.PublicationTS;
            feed.Channel.AddItem(item);

        }

        //using (FileStream stream = new FileStream("SimpleRssFeed.xml", FileMode.Create, FileAccess.Write))
        //{
        Response.ContentType = "application/rss+xml";
        Response.Write(feed.CreateNavigator().OuterXml);

        //}
    }
예제 #8
0
        /// <summary>
        /// Saves the current <see cref="SiteSummaryContentItem"/> 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
            //------------------------------------------------------------
            SiteSummaryContentSyndicationExtension extension    = new SiteSummaryContentSyndicationExtension();

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

            //writer.WriteElementString("format", extension.XmlNamespace, this.Format != null ? this.Format.ToString() : String.Empty);

            //if(this.Encoding != null)
            //{
            //    writer.WriteElementString("encoding", extension.XmlNamespace, this.Encoding.ToString());
            //}

            writer.WriteCData(this.Content);

            writer.WriteEndElement();
        }
예제 #9
0
        /// <summary>
        /// Loads this <see cref="SiteSummaryContentItem"/> 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="SiteSummaryContentItem"/> 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="SiteSummaryContentItem"/>.
        /// </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
            //------------------------------------------------------------
            SiteSummaryContentSyndicationExtension extension    = new SiteSummaryContentSyndicationExtension();
            XmlNamespaceManager manager                         = extension.CreateNamespaceManager(source);

            //------------------------------------------------------------
            //	Attempt to extract syndication information
            //------------------------------------------------------------
            if (source.HasChildren)
            {
                XPathNavigator formatNavigator      = source.SelectSingleNode("content:format", manager);
                XPathNavigator encodingNavigator    = source.SelectSingleNode("content:encoding", manager);

                if (formatNavigator != null)
                {
                    Uri format;
                    if (Uri.TryCreate(formatNavigator.Value, UriKind.RelativeOrAbsolute, out format))
                    {
                        this.Format = format;
                        wasLoaded   = true;
                    }
                }

                if (encodingNavigator != null)
                {
                    Uri encoding;
                    if (Uri.TryCreate(encodingNavigator.Value, UriKind.RelativeOrAbsolute, out encoding))
                    {
                        this.Encoding   = encoding;
                        wasLoaded       = true;
                    }
                }
            }

            if(!String.IsNullOrEmpty(source.Value))
            {
                this.Content    = source.Value;
                wasLoaded       = true;
            }

            return wasLoaded;
        }