Esempio n. 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);
            }
        }
Esempio n. 2
0
 /// <summary>Fins an atomEntry in the collection
 /// based on it's ID. </summary>
 /// <param name="value">The atomId to look for</param>
 /// <returns>Null if not found, otherwise the entry</returns>
 public AtomEntry FindById(AtomId value)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     foreach (AtomEntry entry in List)
     {
         if (entry.Id.AbsoluteUri == value.AbsoluteUri)
         {
             return(entry);
         }
     }
     return(null);
 }
Esempio n. 3
0
        public BloggerAtomId(AtomId id)
        {
            if (id == null) throw new ArgumentNullException("id");

            // Example format this is splitting from: tag:blogger.com,1999:user-10807782958888498623.blog-6374982522691852812

            string[] commaSeparatedItems = id.AbsoluteUri.Split(',');
            Tag = commaSeparatedItems[0];
            Str1999 = commaSeparatedItems[1];

            string[] tagValues = Tag.Split(':');
            TagName = tagValues[1];

            string[] blogValues = Str1999.Split('.');
            BlogUserId = blogValues[0].Split('-')[1];
            BlogId = blogValues[1].Split('-')[1];
        }
Esempio n. 4
0
        /// <summary>
        /// overloaded IComparable interface method
        /// </summary>
        /// <param name="obj">the object to compare this instance with</param>
        /// <returns>int</returns>
        public int CompareTo(object obj)
        {
            AtomId other = obj as AtomId;

            if (other == null)
            {
                return(-1);
            }

            if (this.Uri != null)
            {
                return(this.Uri.CompareTo(other.Uri));
            }

            if (other.Uri == null)
            {
                return(0);
            }

            return(-1);
        }
Esempio n. 5
0
 public Document GetGoogleNoteById(string id)
 {
     AtomId atomId = new AtomId(id);
     foreach (Document note in GoogleNotes)
     {
         if (note.DocumentEntry.Id.Equals(atomId))
             return note;
     }
     return null;
 }
Esempio n. 6
0
 public Group GetGoogleGroupById(string id)
 {
     //return GoogleGroups.FindById(new AtomId(id)) as Group;
     AtomId atomId = new AtomId(id);
     foreach (Group group in GoogleGroups)
     {
         if (group.GroupEntry.Id.Equals(atomId))
             return group;
     }
     return null;
 }
Esempio n. 7
0
 public Contact GetGoogleContactById(string id)
 {
     AtomId atomId = new AtomId(id);
     foreach (Contact contact in GoogleContacts)
     {
         if (contact.ContactEntry.Id.Equals(atomId))
             return contact;
     }
     return null;
 }
Esempio n. 8
0
        private Contact LoadGoogleContacts(AtomId id)
        {
            string message = "Error Loading Google Contacts. Cannot connect to Google.\r\nPlease ensure you are connected to the internet. If you are behind a proxy, change your proxy configuration!";

            Contact ret = null;
            try
            {
                if (id == null) // Only log, if not specific Google Contacts are searched
                    Logger.Log("Loading Google Contacts...", EventType.Information);

                GoogleContacts = new Collection<Contact>();

                ContactsQuery query = new ContactsQuery(ContactsQuery.CreateContactsUri("default"));
                query.NumberToRetrieve = 256;
                query.StartIndex = 0;

                //Only load Google Contacts in My Contacts group (to avoid syncing accounts added automatically to "Weitere Kontakte"/"Further Contacts")
                Group group = GetGoogleGroupByName(myContactsGroup);
                if (group != null)
                    query.Group = group.Id;

                //query.ShowDeleted = false;
                //query.OrderBy = "lastmodified";

                Feed<Contact> feed = ContactsRequest.Get<Contact>(query);

                while (feed != null)
                {
                    foreach (Contact a in feed.Entries)
                    {
                        GoogleContacts.Add(a);
                        if (id != null && id.Equals(a.ContactEntry.Id))
                            ret = a;
                    }
                    query.StartIndex += query.NumberToRetrieve;
                    feed = ContactsRequest.Get<Contact>(feed, FeedRequestType.Next);

                }

            }
            catch (System.Net.WebException ex)
            {
                //Logger.Log(message, EventType.Error);
                throw new GDataRequestException(message, ex);
            }
            catch (System.NullReferenceException ex)
            {
                //Logger.Log(message, EventType.Error);
                throw new GDataRequestException(message, new System.Net.WebException("Error accessing feed", ex));
            }

            return ret;
        }
 public void IdTest()
 {
     AtomEntry target = new AtomEntry(); // TODO: Initialize to an appropriate value
     AtomId expected = new AtomId("http://www.test.com/");
     AtomId actual;
     target.Id = expected;
     actual = target.Id;
     Assert.AreEqual(expected, actual);
 }
 public void op_EqualityTest()
 {
     AtomId a = new AtomId("www.a.com");
     AtomId b = new AtomId("www.b.com");
     bool expected = false; 
     bool actual;
     actual = (a == b);
     Assert.AreEqual(expected, actual);
 }
 public void XmlNameTest()
 {
     AtomId target = new AtomId();
     Assert.AreEqual(AtomParserNameTable.XmlIdElement, target.XmlName);
 }
 public void AtomIdConstructorTest()
 {
     string link = "TestValue"; // TODO: Initialize to an appropriate value
     AtomId target = new AtomId(link);
     Assert.AreEqual(link, target.Uri.ToString());
 }
 public void AtomIdConstructorTest1()
 {
     AtomId target = new AtomId();
     Assert.IsNotNull(target);
     Assert.IsNull(target.Uri);
 }
        public void CompareToTest()
        {
            AtomId a = new AtomId("www.a.com");
            AtomId b = new AtomId("www.a.com");

            int expected = 0;
            int actual;
            actual = a.CompareTo(b);
            Assert.AreEqual(expected, actual);
        }
 public void EqualsTest()
 {
     AtomId a = new AtomId("www.a.com");
     AtomId b = new AtomId("www.b.com");
     bool expected = false; // TODO: Initialize to an appropriate value
     bool actual;
     actual = a.Equals(b);
     Assert.AreEqual(expected, actual);
 }
Esempio n. 16
0
 /// <summary>Fins an atomEntry in the collection 
 /// based on it's ID. </summary> 
 /// <param name="value">The atomId to look for</param> 
 /// <returns>Null if not found, otherwise the entry</returns>
 public AtomEntry FindById( AtomId value )  
 {
     foreach (AtomEntry entry in List)
     {
         if (entry.Id.AbsoluteUri == value.AbsoluteUri)
         {
             return entry;
         }
     }
     return null;
 }
Esempio n. 17
0
        internal Document LoadGoogleNotes(string folderUri, AtomId id)
        {
            string message = "Error Loading Google Notes. Cannot connect to Google.\r\nPlease ensure you are connected to the internet. If you are behind a proxy, change your proxy configuration!";

            Document ret = null;
            try
            {
                if (folderUri == null && id == null)
                {
                    // Only log, if not specific Google Notes are searched
                    Logger.Log("Loading Google Notes...", EventType.Information);
                    GoogleNotes = new Collection<Document>();
                }

                if (googleNotesFolder == null)
                    googleNotesFolder = GetOrCreateGoogleFolder(null, "Notes");//ToDo: Make the folder name Notes configurable in SettingsForm, for now hardcode to "Notes");

                if (folderUri == null)
                {
                    if (id == null)
                        folderUri = googleNotesFolder.DocumentEntry.Content.AbsoluteUri;
                    else //if newly created
                        folderUri = DocumentsRequest.BaseUri;
                }

                DocumentQuery query = new DocumentQuery(folderUri);
                query.Categories.Add(new QueryCategory(new AtomCategory("document")));
                query.NumberToRetrieve = 256;
                query.StartIndex = 0;

                //query.ShowDeleted = false;
                //query.OrderBy = "lastmodified";
                Feed<Document> feed = DocumentsRequest.Get<Document>(query);

                while (feed != null)
                {
                    foreach (Document a in feed.Entries)
                    {
                        if (id == null)
                            GoogleNotes.Add(a);
                        else if (id.Equals(a.DocumentEntry.Id))
                        {
                            ret = a;
                            return ret;
                        }
                    }
                    query.StartIndex += query.NumberToRetrieve;
                    feed = DocumentsRequest.Get<Document>(feed, FeedRequestType.Next);

                }

            }
            catch (System.Net.WebException ex)
            {
                //Logger.Log(message, EventType.Error);
                throw new GDataRequestException(message, ex);
            }
            catch (System.NullReferenceException ex)
            {
                //Logger.Log(message, EventType.Error);
                throw new GDataRequestException(message, new System.Net.WebException("Error accessing feed", ex));
            }

            return ret;
        }
Esempio n. 18
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);
            }
        }
Esempio n. 19
0
 public void IdTest()
 {
     AtomSource target = new AtomSource(); // TODO: Initialize to an appropriate value
     AtomId expected = new AtomId();
     AtomId actual;
     target.Id = expected;
     actual = target.Id;
     Assert.AreEqual(expected, actual);
 }