Пример #1
0
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>takes the updated entry returned and sets the properties to this object</summary>
        /// <param name="updatedEntry"> </param>
        //////////////////////////////////////////////////////////////////////
        protected void CopyEntry(AtomEntry updatedEntry)
        {
            Tracing.Assert(updatedEntry != null, "updatedEntry should not be null");
            if (updatedEntry == null)
            {
                throw new ArgumentNullException("updatedEntry");
            }

            this.title           = updatedEntry.Title;
            this.authors         = updatedEntry.Authors;
            this.id              = updatedEntry.Id;
            this.links           = updatedEntry.Links;
            this.lastUpdateDate  = updatedEntry.Updated;
            this.publicationDate = updatedEntry.Published;
            this.authors         = updatedEntry.Authors;
            this.rights          = updatedEntry.Rights;
            this.categories      = updatedEntry.Categories;
            this.summary         = updatedEntry.Summary;
            this.content         = updatedEntry.Content;
            this.source          = updatedEntry.Source;

            this.ExtensionElements.Clear();

            foreach (IExtensionElementFactory extension in updatedEntry.ExtensionElements)
            {
                this.ExtensionElements.Add(extension);
            }
        }
Пример #2
0
 public void ItemTest()
 {
     AtomCategoryCollection target = new AtomCategoryCollection();
     int index = 0; 
     AtomCategory expected = new AtomCategory("test");
     AtomCategory actual;
     target.Add(expected);
     target[index] = expected;
     actual = target[index];
     Assert.AreEqual(expected, actual);
 }
Пример #3
0
 public String getCategoryLabel(AtomCategoryCollection categories)
 {
     foreach (AtomCategory cat in categories)
     {
         if (cat.Scheme == SitesService.KIND_SCHEME)
         {
             return cat.Label;
         }
     }
     return null;
 }
Пример #4
0
        /// <summary>tries to parse a category collection document</summary>
        /// <param name="reader"> xmlReader positioned at the start element</param>
        /// <param name="owner">the base object that the collection belongs to</param>
        /// <returns></returns>
        public AtomCategoryCollection ParseCategories(XmlReader reader, AtomBase owner)
        {
            Tracing.Assert(reader != null, "reader should not be null");
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            AtomCategoryCollection ret = new AtomCategoryCollection();

            MoveToStartElement(reader);

            Tracing.TraceCall("entering Categories Parser");
            object localname = reader.LocalName;

            Tracing.TraceInfo("localname is: " + reader.LocalName);

            if (IsCurrentNameSpace(reader, BaseNameTable.AppPublishingNamespace(owner)) &&
                localname.Equals(this.nameTable.Categories))
            {
                Tracing.TraceInfo("Found categories  document");
                int depth = -1;
                while (NextChildElement(reader, ref depth))
                {
                    localname = reader.LocalName;
                    if (IsCurrentNameSpace(reader, BaseNameTable.NSAtom))
                    {
                        if (localname.Equals(this.nameTable.Category))
                        {
                            AtomCategory category = ParseCategory(reader, owner);
                            ret.Add(category);
                        }
                    }
                }
            }
            else
            {
                Tracing.TraceInfo("ParseCategories called and nothing was parsed" + localname);
                throw new ClientFeedException("An invalid Atom Document was passed to the parser. This was not an app:categories document: " + localname);
            }

            return(ret);
        }
Пример #5
0
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>public AtomSource(AtomFeed feed)</summary>
        //////////////////////////////////////////////////////////////////////
        public AtomSource(AtomFeed feed) : this()
        {
            Tracing.Assert(feed != null, "feed should not be null");
            if (feed == null)
            {
                throw new ArgumentNullException("feed");
            }

            // now copy them
            this.authors      = feed.Authors;
            this.contributors = feed.Contributors;
            this.categories   = feed.Categories;
            this.Generator    = feed.Generator;
            this.Icon         = feed.Icon;
            this.Logo         = feed.Logo;
            this.Id           = feed.Id;
            this.links        = feed.Links;
            this.Rights       = feed.Rights;
            this.Subtitle     = feed.Subtitle;
            this.Title        = feed.Title;
            this.Updated      = feed.Updated;
        }
Пример #6
0
        /// <summary>public AtomSource(AtomFeed feed)</summary> 
        public AtomSource(AtomFeed feed)
            : this() {
            Tracing.Assert(feed != null, "feed should not be null");
            if (feed == null) {
                throw new ArgumentNullException("feed");
            }

            // now copy them
            this.authors = feed.Authors;
            this.contributors = feed.Contributors;
            this.categories = feed.Categories;
            this.Generator = feed.Generator;
            this.Icon = feed.Icon;
            this.Logo = feed.Logo;
            this.Id = feed.Id;
            this.links = feed.Links;
            this.Rights = feed.Rights;
            this.Subtitle = feed.Subtitle;
            this.Title = feed.Title;
            this.Updated = feed.Updated;
        }
Пример #7
0
       /////////////////////////////////////////////////////////////////////////////


       //////////////////////////////////////////////////////////////////////
       /// <summary>verifies the categroy collection</summary> 
       /// <param name="theOne">the One Collection </param>
       /// <param name="theOther">the Other Collection </param>
       /// <returns>true if identical </returns>
       //////////////////////////////////////////////////////////////////////
       public static bool IsCategoryCollectionIdentical(AtomCategoryCollection theOne, AtomCategoryCollection theOther)
       {
           if (theOne == null && theOther == null)
           {
               return true;
           }

           if (theOne.Count != theOther.Count)
           {
               return false;
           }
           for (int i=0; i< theOne.Count; i++)
           {
               if (IsCategoryIdentical(theOne[i], theOther[i])==false)
               {
                   return false;
               }

           }


           return true;
       }
Пример #8
0
        /// <summary>takes the updated entry returned and sets the properties to this object</summary> 
        /// <param name="updatedEntry"> </param>
        protected void CopyEntry(AtomEntry updatedEntry) {
            Tracing.Assert(updatedEntry != null, "updatedEntry should not be null");
            if (updatedEntry == null) {
                throw new ArgumentNullException("updatedEntry");
            }

            this.title = updatedEntry.Title;
            this.authors = updatedEntry.Authors;
            this.id = updatedEntry.Id;
            this.links = updatedEntry.Links;
            this.lastUpdateDate = updatedEntry.Updated;
            this.publicationDate = updatedEntry.Published;
            this.authors = updatedEntry.Authors;
            this.rights = updatedEntry.Rights;
            this.categories = updatedEntry.Categories;
            this.summary = updatedEntry.Summary;
            this.content = updatedEntry.Content;
            this.source = updatedEntry.Source;

            this.ExtensionElements.Clear();

            foreach (IExtensionElementFactory extension in updatedEntry.ExtensionElements) {
                this.ExtensionElements.Add(extension);
            }
        }
Пример #9
0
        /// <summary>tries to parse a category collection document</summary> 
        /// <param name="reader"> xmlReader positioned at the start element</param>
        /// <param name="owner">the base object that the collection belongs to</param>
        /// <returns></returns>
        public AtomCategoryCollection ParseCategories(XmlReader reader, AtomBase owner) {
            Tracing.Assert(reader != null, "reader should not be null");
            if (reader == null) {
                throw new ArgumentNullException("reader");
            }
            AtomCategoryCollection ret = new AtomCategoryCollection();
            MoveToStartElement(reader);

            Tracing.TraceCall("entering Categories Parser");
            object localname = reader.LocalName;
            Tracing.TraceInfo("localname is: " + reader.LocalName);

            if (IsCurrentNameSpace(reader, BaseNameTable.AppPublishingNamespace(owner)) &&
                localname.Equals(this.nameTable.Categories)) {
                Tracing.TraceInfo("Found categories  document");
                int depth = -1;
                while (NextChildElement(reader, ref depth)) {
                    localname = reader.LocalName;
                    if (IsCurrentNameSpace(reader, BaseNameTable.NSAtom)) {
                        if (localname.Equals(this.nameTable.Category)) {
                            AtomCategory category = ParseCategory(reader, owner);
                            ret.Add(category);
                        }
                    }
                }
            } else {
                Tracing.TraceInfo("ParseCategories called and nothing was parsed" + localname);
                throw new ClientFeedException("An invalid Atom Document was passed to the parser. This was not an app:categories document: " + localname);
            }

            return ret;
        }
Пример #10
0
        public void RemoveTest()
        {
            AtomCategoryCollection target = new AtomCategoryCollection(); // TODO: Initialize to an appropriate value
            AtomCategory expected = new AtomCategory("test");

            Assert.IsTrue(target.Count == 0);
            target.Add(expected);
            Assert.IsTrue(target.Count == 1);
            target.Remove(expected);
            Assert.IsTrue(target.Count == 0);
        }
Пример #11
0
 public void AddTest()
 {
     AtomCategoryCollection target = new AtomCategoryCollection(); // TODO: Initialize to an appropriate value
     AtomCategory value = new AtomCategory("test");
     target.Add(value);
     Assert.IsTrue(target.Contains(value)); 
 }
Пример #12
0
 public void FindTest()
 {
     AtomCategoryCollection target = new AtomCategoryCollection(); // TODO: Initialize to an appropriate value
     AtomCategory value = new AtomCategory("test");
     target.Add(value);
     string term = "test";
     AtomCategory actual;
     actual = target.Find(term);
     Assert.AreEqual(value, actual);
 }
Пример #13
0
        public void IndexOfTest()
        {
            AtomCategoryCollection target = new AtomCategoryCollection(); // TODO: Initialize to an appropriate value
            AtomCategory value = new AtomCategory("test");

            target.Add(value);
            int expected = 0; // TODO: Initialize to an appropriate value
            int actual;
            actual = target.IndexOf(value);
            Assert.AreEqual(expected, actual);
        }
Пример #14
0
 public void InsertTest()
 {
     AtomCategoryCollection target = new AtomCategoryCollection(); // TODO: Initialize to an appropriate value
     AtomCategory value = new AtomCategory("test");
     int index = 0; 
     Assert.IsTrue(target.Count == 0);
     target.Insert(index, value);
     Assert.IsTrue(target.Count == 1);
 }