/// <summary>
        /// Modifies the <see cref="AtomEntry"/> collection entities to match the supplied <see cref="XPathNavigator"/> data source.
        /// </summary>
        /// <param name="entry">The <see cref="AtomEntry"/> to be filled.</param>
        /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param>
        /// <param name="manager">The <see cref="XmlNamespaceManager"/> used to resolve XML namespace prefixes.</param>
        /// <param name="settings">The <see cref="SyndicationResourceLoadSettings"/> used to configure the fill operation.</param>
        /// <remarks>
        ///     This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents a <see cref="AtomEntry"/>.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="entry"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="manager"/> 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>
        private static void FillEntryCollections(AtomEntry entry, XPathNavigator source, XmlNamespaceManager manager, SyndicationResourceLoadSettings settings)
        {
            Guard.ArgumentNotNull(entry, "entry");
            Guard.ArgumentNotNull(source, "source");
            Guard.ArgumentNotNull(manager, "manager");
            Guard.ArgumentNotNull(settings, "settings");

            XPathNodeIterator authorIterator      = source.Select("atom:author", manager);
            XPathNodeIterator categoryIterator    = source.Select("atom:category", manager);
            XPathNodeIterator contributorIterator = source.Select("atom:contributor", manager);
            XPathNodeIterator linkIterator        = source.Select("atom:link", manager);

            if (authorIterator != null && authorIterator.Count > 0)
            {
                while (authorIterator.MoveNext())
                {
                    AtomPersonConstruct author = new AtomPersonConstruct();
                    if (author.Load(authorIterator.Current, settings))
                    {
                        entry.Authors.Add(author);
                    }
                }
            }

            if (categoryIterator != null && categoryIterator.Count > 0)
            {
                while (categoryIterator.MoveNext())
                {
                    AtomCategory category = new AtomCategory();
                    if (category.Load(categoryIterator.Current, settings))
                    {
                        entry.Categories.Add(category);
                    }
                }
            }

            if (contributorIterator != null && contributorIterator.Count > 0)
            {
                while (contributorIterator.MoveNext())
                {
                    AtomPersonConstruct contributor = new AtomPersonConstruct();
                    if (contributor.Load(contributorIterator.Current, settings))
                    {
                        entry.Contributors.Add(contributor);
                    }
                }
            }

            if (linkIterator != null && linkIterator.Count > 0)
            {
                while (linkIterator.MoveNext())
                {
                    AtomLink link = new AtomLink();
                    if (link.Load(linkIterator.Current, settings))
                    {
                        entry.Links.Add(link);
                    }
                }
            }
        }
コード例 #2
0
        public virtual void Save(XmlWriter writer)
        {
            Uri feedID = GenerateUniqueID();
              AtomTextConstruct feedTitle = new AtomTextConstruct(string.Empty);
              DateTime feedUpdated = DateTime.Now;
              AtomFeed feed = new SettingsFeed(feedID, feedTitle, feedUpdated);

              AtomPersonConstruct feedAuthor = new AtomPersonConstruct(string.Empty);
              feed.AddAuthor(feedAuthor);

              foreach (SettingsItemInfo info in this) {
            Uri entryID = info.ID;
            AtomTextConstruct entryTitle = new AtomTextConstruct(info.Name);
            DateTime entryUpdated = feedUpdated;

            SettingsEntry entry = new SettingsEntry(entryID, entryTitle, entryUpdated);

            string valueString = ConvertToString(info.Value);
            AtomContent content = new AtomContent(valueString);
            entry.Content = content;
            entry.Type = info.Type;

            feed.Entries.Add(entry);
              }

              feed.WriteDocument(writer);
        }
コード例 #3
0
        /// <summary>
        /// Creates a <see cref="AtomPersonConstruct"/> using the supplied <see cref="XPathNavigator"/>.
        /// </summary>
        /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param>
        /// <param name="manager">The <see cref="XmlNamespaceManager"/> used to resolve XML namespace prefixes.</param>
        /// <param name="settings">The <see cref="SyndicationResourceLoadSettings"/> used to configure the fill operation.</param>
        /// <returns>A <see cref="AtomPersonConstruct"/> instance initialized using the supplied <paramref name="source"/>.</returns>
        /// <remarks>
        ///     This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents a Atom 0.3 Person construct.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="manager"/> 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>
        private static AtomPersonConstruct CreatePerson(XPathNavigator source, XmlNamespaceManager manager, SyndicationResourceLoadSettings settings)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            AtomPersonConstruct person = new AtomPersonConstruct();

            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(source, "source");
            Guard.ArgumentNotNull(manager, "manager");
            Guard.ArgumentNotNull(settings, "settings");

            //------------------------------------------------------------
            //	Attempt to extract common attributes information
            //------------------------------------------------------------
            AtomUtility.FillCommonObjectAttributes(person, source);

            //------------------------------------------------------------
            //	Attempt to extract syndication information
            //------------------------------------------------------------
            XPathNavigator nameNavigator  = source.SelectSingleNode("atom:name", manager);
            XPathNavigator urlNavigator   = source.SelectSingleNode("atom:url", manager);
            XPathNavigator emailNavigator = source.SelectSingleNode("atom:email", manager);

            if (nameNavigator != null)
            {
                person.Name = nameNavigator.Value;
            }

            if (urlNavigator != null)
            {
                Uri uri;
                if (Uri.TryCreate(urlNavigator.Value, UriKind.RelativeOrAbsolute, out uri))
                {
                    person.Uri = uri;
                }
            }

            if (emailNavigator != null)
            {
                person.EmailAddress = emailNavigator.Value;
            }

            SyndicationExtensionAdapter adapter = new SyndicationExtensionAdapter(source, settings);

            adapter.Fill(person, manager);

            return(person);
        }
コード例 #4
0
        public void TestAuthor()
        {
            AtomPersonConstruct author = new AtomPersonConstruct();

            author.Email = "*****@*****.**";
            author.Name  = "Uncle Tom";
            author.Url   = testUri;

            feed.Author = author;

            Assert.AreEqual(author.LocalName, "author");
            Assert.AreEqual(author.FullName, "atom:author");
            Assert.AreSame(feed.Author, author);
        }
コード例 #5
0
        public void TestContributors()
        {
            AtomPersonConstruct contributor = new AtomPersonConstruct("contributor");

            contributor.Email = "*****@*****.**";
            contributor.Name  = "Uncle Bob";
            contributor.Url   = testUri;

            feed.Contributors.Add(contributor);

            Assert.AreEqual(contributor.LocalName, "contributor");
            Assert.AreEqual(contributor.FullName, "atom:contributor");
            Assert.AreSame(feed.Contributors[0], contributor);
            Assert.AreEqual(feed.Contributors[0], contributor);
        }
コード例 #6
0
ファイル: AtomEntryTest.cs プロジェクト: qwdf1615/sncore
        public void TestContributors()
        {
            AtomPersonConstruct contributor = new AtomPersonConstruct("contributor", new Uri("http://purl.org/atom/ns#"));

            contributor.Email = "*****@*****.**";
            contributor.Name  = "Uncle Bob";
            contributor.Url   = testUri;

            entry.Contributors.Add(contributor);


            Assert.AreEqual(contributor.LocalName, "contributor");
            Assert.AreEqual(contributor.FullName, "atom:contributor");
            Assert.AreSame(entry.Contributors[0], contributor);
            Assert.AreEqual(entry.Contributors[0], contributor);
        }
コード例 #7
0
ファイル: AtomEntryTest.cs プロジェクト: qwdf1615/sncore
        public void TestAuthor()
        {
            AtomPersonConstruct author = new AtomPersonConstruct(new Uri("http://purl.org/atom/ns#"));

            author.Email = "*****@*****.**";
            author.Name  = "Uncle Tom";
            author.Url   = testUri;

            entry.Author = author;

            entry.Author.ToString();

            Assert.AreEqual(author.LocalName, "author");
            Assert.AreEqual(author.FullName, "atom:author");
            Assert.AreSame(entry.Author, author);
        }
コード例 #8
0
        /// <summary>
        /// Modifies the <see cref="AtomEntry"/> collection entities to match the supplied <see cref="XPathNavigator"/> data source.
        /// </summary>
        /// <param name="entry">The <see cref="AtomEntry"/> to be filled.</param>
        /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param>
        /// <param name="manager">The <see cref="XmlNamespaceManager"/> used to resolve XML namespace prefixes.</param>
        /// <param name="settings">The <see cref="SyndicationResourceLoadSettings"/> used to configure the fill operation.</param>
        /// <remarks>
        ///     This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents an Atom 0.3 element.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="entry"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="manager"/> 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>
        private static void FillEntryCollections(AtomEntry entry, XPathNavigator source, XmlNamespaceManager manager, SyndicationResourceLoadSettings settings)
        {
            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(entry, "entry");
            Guard.ArgumentNotNull(source, "source");
            Guard.ArgumentNotNull(manager, "manager");
            Guard.ArgumentNotNull(settings, "settings");

            //------------------------------------------------------------
            //	Attempt to extract syndication information
            //------------------------------------------------------------
            XPathNodeIterator authorIterator      = source.Select("atom:author", manager);
            XPathNodeIterator contributorIterator = source.Select("atom:contributor", manager);
            XPathNodeIterator linkIterator        = source.Select("atom:link", manager);

            if (authorIterator != null && authorIterator.Count > 0)
            {
                while (authorIterator.MoveNext())
                {
                    AtomPersonConstruct author = Atom03SyndicationResourceAdapter.CreatePerson(authorIterator.Current, manager, settings);
                    entry.Authors.Add(author);
                }
            }

            if (contributorIterator != null && contributorIterator.Count > 0)
            {
                while (contributorIterator.MoveNext())
                {
                    AtomPersonConstruct contributor = Atom03SyndicationResourceAdapter.CreatePerson(contributorIterator.Current, manager, settings);
                    entry.Contributors.Add(contributor);
                }
            }

            if (linkIterator != null && linkIterator.Count > 0)
            {
                while (linkIterator.MoveNext())
                {
                    AtomLink link = new AtomLink();
                    if (link.Load(linkIterator.Current, settings))
                    {
                        entry.Links.Add(link);
                    }
                }
            }
        }
コード例 #9
0
        //============================================================
        //	CLASS SUMMARY
        //============================================================
        /// <summary>
        /// Provides example code for the AtomPersonConstruct class.
        /// </summary>
        public static void ClassExample()
        {
            #region AtomPersonConstruct
            AtomFeed feed = new AtomFeed();

            feed.Id        = new AtomId(new Uri("urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6"));
            feed.Title     = new AtomTextConstruct("Example Feed");
            feed.UpdatedOn = new DateTime(2003, 12, 13, 18, 30, 2);

            feed.Links.Add(new AtomLink(new Uri("http://example.org/")));
            feed.Links.Add(new AtomLink(new Uri("/feed"), "self"));

            //  Identify the author of the feed
            feed.Authors.Add(new AtomPersonConstruct("John Doe"));

            //  Identify the contributors to the feed
            feed.Contributors.Add(new AtomPersonConstruct("Jane Doe"));

            AtomPersonConstruct contributor = new AtomPersonConstruct();
            contributor.EmailAddress = "*****@*****.**";
            contributor.Name         = "Some Person";
            contributor.Uri          = new Uri("http://example.org/somePerson");
            feed.Contributors.Add(contributor);

            AtomEntry entry = new AtomEntry();

            entry.Id        = new AtomId(new Uri("urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a"));
            entry.Title     = new AtomTextConstruct("Atom-Powered Robots Run Amok");
            entry.UpdatedOn = new DateTime(2003, 12, 13, 18, 30, 2);

            entry.Summary = new AtomTextConstruct("Some text.");

            //  Identify the author of the entry
            entry.Authors.Add(new AtomPersonConstruct("Jane Doe"));

            feed.AddEntry(entry);
            #endregion
        }
コード例 #10
0
 /// <summary>Inserts a <see cref="AtomPersonConstruct"/> into this collection at the specified index.</summary>
 /// <param name="index">The zero-based index of the collection at which <i>contributor</i> should be inserted.</param>
 /// <param name="contributor">The <see cref="AtomPersonConstruct"/> to insert into this collection.</param>
 public void Insert(int index, AtomPersonConstruct contributor)
 {
     List.Insert(index, contributor);
 }
コード例 #11
0
		/// <summary>
		/// Searches for the specified <see cref="AtomPersonConstruct"/> and returns the zero-based index of the first occurrence
		/// within the entire <see cref="AtomPersonConstructCollection"/>.
		/// </summary>
		/// <param name="contributor">The <see cref="AtomPersonConstruct"/> to locate in the <see cref="AtomPersonConstructCollection"/>.</param>
		/// <returns>The zero-based index of the first occurrence of <i>contributor</i> within the entire <see cref="AtomPersonConstructCollection"/>,
		/// if found; otherwise, -1.</returns>
		public int IndexOf(AtomPersonConstruct contributor)
		{
			return List.IndexOf(contributor);
		}
コード例 #12
0
		/// <summary>
		/// Determines whether the <see cref="AtomPersonConstructCollection"/> contains a specific element.
		/// </summary>
		/// <param name="contributor">The <see cref="AtomPersonConstruct"/> to locate in the <see cref="AtomPersonConstructCollection"/>.</param>
		/// <returns>true if the <see cref="AtomPersonConstructCollection"/> contains the specified item, otherwise false.</returns>
		public bool Contains(AtomPersonConstruct contributor)
		{
			return this.List.Contains(contributor);
		}
コード例 #13
0
		/// <summary>
		/// Adds an object to the end of the <see cref="AtomPersonConstructCollection"/>.
		/// </summary>
		/// <param name="contributor">The <see cref="AtomPersonConstruct"/> to be added to the end of
		/// the <see cref="AtomPersonConstructCollection"/>.</param>
		/// <returns>The <see cref="AtomPersonConstructCollection"/> index at which the value has been added.</returns>
		public int Add(AtomPersonConstruct contributor)
		{
			return this.List.Add(contributor);
		}
コード例 #14
0
 /// <summary>
 /// Determines whether the <see cref="AtomPersonConstructCollection"/> contains a specific element.
 /// </summary>
 /// <param name="contributor">The <see cref="AtomPersonConstruct"/> to locate in the <see cref="AtomPersonConstructCollection"/>.</param>
 /// <returns>true if the <see cref="AtomPersonConstructCollection"/> contains the specified item, otherwise false.</returns>
 public bool Contains(AtomPersonConstruct contributor)
 {
     return(this.List.Contains(contributor));
 }
コード例 #15
0
 /// <summary>Removes the first occurrence of a specific <see cref="AtomPersonConstruct"/>
 /// from the <see cref="AtomPersonConstructCollection"/>.</summary>
 /// <param name="contributor">The <see cref="AtomPersonConstruct"/> to remove from the <see cref="AtomPersonConstructCollection"/>.</param>
 public void Remove(AtomPersonConstruct contributor)
 {
     List.Remove(contributor);
 }
コード例 #16
0
ファイル: AtomDocument.cs プロジェクト: hazychill/webfeed
 public void AddContributor(AtomPersonConstruct contributor)
 {
     Helper.AddItem<AtomPersonConstruct>(ref _contributors, contributor);
 }
コード例 #17
0
ファイル: AtomDocument.cs プロジェクト: hazychill/webfeed
 public void AddAuthor(AtomPersonConstruct author)
 {
     Helper.AddItem<AtomPersonConstruct>(ref _authors, author);
 }
        /// <summary>
        /// Modifies the <see cref="AtomFeed"/> collection entities to match the supplied <see cref="XPathNavigator"/> data source.
        /// </summary>
        /// <param name="feed">The <see cref="AtomFeed"/> to be filled.</param>
        /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param>
        /// <param name="manager">The <see cref="XmlNamespaceManager"/> used to resolve XML namespace prefixes.</param>
        /// <param name="settings">The <see cref="SyndicationResourceLoadSettings"/> used to configure the fill operation.</param>
        /// <remarks>
        ///     This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents a <see cref="AtomFeed"/>.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="feed"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="manager"/> 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>
        private static void FillFeedCollections(AtomFeed feed, XPathNavigator source, XmlNamespaceManager manager, SyndicationResourceLoadSettings settings)
        {
            Guard.ArgumentNotNull(feed, "feed");
            Guard.ArgumentNotNull(source, "source");
            Guard.ArgumentNotNull(manager, "manager");
            Guard.ArgumentNotNull(settings, "settings");

            XPathNodeIterator authorIterator      = source.Select("atom:author", manager);
            XPathNodeIterator contributorIterator = source.Select("atom:contributor", manager);
            XPathNodeIterator linkIterator        = source.Select("atom:link", manager);
            XPathNodeIterator entryIterator       = source.Select("atom:entry", manager);

            if (authorIterator != null && authorIterator.Count > 0)
            {
                while (authorIterator.MoveNext())
                {
                    AtomPersonConstruct author = Atom03SyndicationResourceAdapter.CreatePerson(authorIterator.Current, manager, settings);
                    feed.Authors.Add(author);
                }
            }

            if (contributorIterator != null && contributorIterator.Count > 0)
            {
                while (contributorIterator.MoveNext())
                {
                    AtomPersonConstruct contributor = Atom03SyndicationResourceAdapter.CreatePerson(contributorIterator.Current, manager, settings);
                    feed.Contributors.Add(contributor);
                }
            }

            if (entryIterator != null && entryIterator.Count > 0)
            {
                int counter = 0;
                while (entryIterator.MoveNext())
                {
                    AtomEntry entry = new AtomEntry();
                    counter++;

                    Atom03SyndicationResourceAdapter.FillEntry(entry, entryIterator.Current, manager, settings);

                    if (settings.RetrievalLimit != 0 && counter > settings.RetrievalLimit)
                    {
                        break;
                    }

                    ((Collection <AtomEntry>)feed.Entries).Add(entry);
                }
            }

            if (linkIterator != null && linkIterator.Count > 0)
            {
                while (linkIterator.MoveNext())
                {
                    AtomLink link = new AtomLink();
                    if (link.Load(linkIterator.Current, settings))
                    {
                        feed.Links.Add(link);
                    }
                }
            }
        }
コード例 #19
0
 /// <summary>
 /// Adds an object to the end of the <see cref="AtomPersonConstructCollection"/>.
 /// </summary>
 /// <param name="contributor">The <see cref="AtomPersonConstruct"/> to be added to the end of
 /// the <see cref="AtomPersonConstructCollection"/>.</param>
 /// <returns>The <see cref="AtomPersonConstructCollection"/> index at which the value has been added.</returns>
 public int Add(AtomPersonConstruct contributor)
 {
     return(this.List.Add(contributor));
 }
コード例 #20
0
		/// <summary>Inserts a <see cref="AtomPersonConstruct"/> into this collection at the specified index.</summary>
		/// <param name="index">The zero-based index of the collection at which <i>contributor</i> should be inserted.</param>
		/// <param name="contributor">The <see cref="AtomPersonConstruct"/> to insert into this collection.</param>
		public void Insert(int index, AtomPersonConstruct contributor)
		{
			List.Insert(index, contributor);
		}
コード例 #21
0
 /// <summary>
 /// Searches for the specified <see cref="AtomPersonConstruct"/> and returns the zero-based index of the first occurrence
 /// within the entire <see cref="AtomPersonConstructCollection"/>.
 /// </summary>
 /// <param name="contributor">The <see cref="AtomPersonConstruct"/> to locate in the <see cref="AtomPersonConstructCollection"/>.</param>
 /// <returns>The zero-based index of the first occurrence of <i>contributor</i> within the entire <see cref="AtomPersonConstructCollection"/>,
 /// if found; otherwise, -1.</returns>
 public int IndexOf(AtomPersonConstruct contributor)
 {
     return(List.IndexOf(contributor));
 }
コード例 #22
0
		/// <summary>Removes the first occurrence of a specific <see cref="AtomPersonConstruct"/>
		/// from the <see cref="AtomPersonConstructCollection"/>.</summary>
		/// <param name="contributor">The <see cref="AtomPersonConstruct"/> to remove from the <see cref="AtomPersonConstructCollection"/>.</param>
		public void Remove(AtomPersonConstruct contributor)
		{
			List.Remove(contributor);
		}