Example #1
0
        //////////////////////////////////////////////////////////////////////
        /// <summary>creates a new, in memory atom entry</summary> 
        /// <returns>the new AtomEntry </returns>
        //////////////////////////////////////////////////////////////////////
        public static AtomEntry CreateAtomEntry(int iCount)
        {
            AtomEntry entry = new AtomEntry();
            // some unicode chars
            Char[] chars = new Char[] {
            '\u0023', // #
            '\u0025', // %
            '\u03a0', // Pi
            '\u03a3',  // Sigma
            '\u03d1', // beta
            '&',
            };

            AtomPerson author = new AtomPerson(AtomPersonType.Author);
            author.Name = "John Doe" + chars[0] + chars[1] + chars[2] + chars[3] + chars[4] + chars[5]; 
            author.Email = "*****@*****.**";
            entry.Authors.Add(author);
    
            AtomCategory cat = new AtomCategory();
    
            cat.Label = "Default";
            cat.Term = "Default" + chars[4] + " Term";
            entry.Categories.Add(cat);
    
            entry.Content.Content = "this is the default text & entry";
            entry.Content.Type = "html"; 
            entry.Published = new DateTime(2001, 11, 20, 22, 30, 0);  
            entry.Title.Text = "This is a entry number: " + iCount;
            entry.Updated = DateTime.Now; 

    
            return entry;
        }
        public void XmlNameTest()
        {
            AtomPerson target = new AtomPerson(); 
            Assert.AreEqual(target.XmlName, AtomParserNameTable.XmlAuthorElement);

            target = new AtomPerson(AtomPersonType.Contributor);
            Assert.AreEqual(target.XmlName, AtomParserNameTable.XmlContributorElement);
            
        }
		public static Author FromAtomPerson(AtomPerson person)
		{
			Author author = new Author();
			author.Uri = person.Uri.Content;
			author.Language = person.Language;	
			author.Email = person.Email;
			author.Name = person.Name;

			return author;
		}
        ///<summary>Standard type converter method</summary>
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, System.Type destinationType)
        {
            AtomPerson person = value as AtomPerson;

            if (destinationType == typeof(System.String) && person != null)
            {
                return("Person: " + person.Name);
            }
            return(base.ConvertTo(context, culture, value, destinationType));
        }
        /// <summary>parses an author/person object</summary>
        /// <param name="reader"> an XmlReader positioned at the start of the author</param>
        /// <param name="owner">the object containing the person</param>
        /// <returns> the created author object</returns>
        protected AtomPerson ParsePerson(XmlReader reader, AtomBase owner)
        {
            Tracing.Assert(reader != null, "reader should not be null");
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            Tracing.Assert(owner != null, "owner should not be null");
            if (owner == null)
            {
                throw new ArgumentNullException("owner");
            }

            Tracing.TraceCall();
            object     localname = null;
            AtomPerson author    = owner.CreateAtomSubElement(reader, this) as AtomPerson;

            ParseBasicAttributes(reader, author);

            int lvl = -1;

            while (NextChildElement(reader, ref lvl))
            {
                localname = reader.LocalName;

                if (localname.Equals(this.nameTable.Name))
                {
                    // author.Name = Utilities.DecodeString(Utilities.DecodedValue(reader.ReadString()));
                    author.Name = Utilities.DecodedValue(reader.ReadString());
                    reader.Read();
                }
                else if (localname.Equals(this.nameTable.Uri))
                {
                    author.Uri = new AtomUri(Utilities.DecodedValue(reader.ReadString()));
                    reader.Read();
                }
                else if (localname.Equals(this.nameTable.Email))
                {
                    author.Email = Utilities.DecodedValue(reader.ReadString());
                    reader.Read();
                }
                else
                {
                    // default extension parsing.
                    ParseExtensionElements(reader, author);
                }
            }
            return(author);
        }
        private EventEntry CreateEventEntry( int entryNumber )
        {
            var entry = new EventEntry
            {
                Content = { Content = "This is the default text entry." },
                Published = new DateTime( 2001, 1, 1 ),
                Title = { Text = "This is a entry number: " + entryNumber },
                Updated = DateTime.Now,
            };

            var author = new AtomPerson( AtomPersonType.Author )
            {
                Name = "nCubed",
                Email = "*****@*****.**",
            };
            entry.Authors.Add( author );

            var cat = new AtomCategory
            {
                Label = "Default",
                Term = "Default Term",
            };
            entry.Categories.Add( cat );

            var newTime = new When
            {
                StartTime = DateTime.Today,
                EndTime = DateTime.Today.AddDays( 1 )
            };
            entry.Times.Add( newTime );

            return entry;
        }
Example #7
0
 /// <summary>standard typed accessor method </summary> 
 public int IndexOf( AtomPerson value )  
 {
     return( List.IndexOf( value ) );
 }
Example #8
0
       /////////////////////////////////////////////////////////////////////////////


       //////////////////////////////////////////////////////////////////////
       /// <summary>public static bool IsPersonIdentical(AtomPerson theOne, AtomPerson theOther)</summary> 
       /// <param name="theOne">the One Person </param>
       /// <param name="theOther">the Other Person</param>
       /// <returns>true if identical </returns>
       //////////////////////////////////////////////////////////////////////
       public static bool IsPersonIdentical(AtomPerson theOne, AtomPerson theOther)
       {
           if (theOne == null && theOther == null)
           {
               return true;
           }

           if (ObjectModelHelper.IsBaseIdentical(theOne, theOther)==false)
           {
               Tracing.TraceInfo("IsPersonIdentical: comparing  base failed");
               return false;
           }
           Tracing.TraceInfo("IsPersonIdentical: comparing  Name " + theOne.Name + " " + theOther.Name);

           if (String.Compare(theOne.Email, theOther.Email)!=0)
           {
               Tracing.TraceInfo("IsPersonIdentical: comparing  email failed" + theOne.Email + " " + theOther.Email);
               return false;
           }
           if (String.Compare(theOne.Name, theOther.Name)!=0)
           {
               Tracing.TraceInfo("IsPersonIdentical: comparing  Name failed" + theOne.Name + " " + theOther.Name);
               return false;
           }
           if (AtomUri.Compare(theOne.Uri, theOther.Uri) != 0)
           {
               Tracing.TraceInfo("IsPersonIdentical: comparing  URI failed - " + theOne.Uri.ToString() + " " + theOther.Uri.ToString());
               return false;
           }
           return true;
       }
Example #9
0
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>creates a new, in memory atom entry</summary> 
        /// <returns>the new AtomEntry </returns>
        //////////////////////////////////////////////////////////////////////
        public static EventEntry CreateEventEntry(int iCount)
        {
            EventEntry entry = new EventEntry();
            // some unicode chars
            Char[] chars = new Char[] {
                                          '\u0023', // #
                                          '\u0025', // %
                                          '\u03a0', // Pi
                                          '\u03a3',  // Sigma
                                          '\u03d1', // beta
            };

            // if unicode needs to be disabled for testing, just uncomment this line
            // chars = new Char[] { 'a', 'b', 'c', 'd', 'e'}; 

    
    
            AtomPerson author = new AtomPerson(AtomPersonType.Author);
            author.Name = "John Doe" + chars[0] + chars[1] + chars[2] + chars[3]; 
            author.Email = "*****@*****.**";
            entry.Authors.Add(author);
    
            AtomCategory cat = new AtomCategory();
    
            cat.Label = "Default";
            cat.Term = "Default" + chars[4] + " Term";
            entry.Categories.Add(cat);
    
            entry.Content.Content = "this is the default text entry";
            entry.Published = new DateTime(2001, 11, 20, 22, 30, 0);  
            entry.Title.Text = "This is a entry number: " + iCount;
            entry.Updated = DateTime.Now; 

            When newTime = new When();
            newTime.StartTime = DateTime.Today.AddDays(-3);
            newTime.EndTime = DateTime.Today.AddDays(1);
            entry.Times.Add(newTime);


            entry.Reminder = new Reminder();
            entry.Reminder.Minutes = DEFAULT_REMINDER_TIME; 

            Who someone = new Who();
            someone.ValueString = "*****@*****.**";
            Who.AttendeeStatus status = new Who.AttendeeStatus();
            status.Value = "event.accepted"; 
            someone.Attendee_Status = status;
            someone.Rel = "http://schemas.google.com/g/2005#event.organizer";

            entry.Participants.Add(someone);


            Where newPlace = new Where();
            newPlace.ValueString = "A really nice place";
            entry.Locations.Add(newPlace);
            newPlace = new Where();
            newPlace.ValueString = "Another really nice place";
            newPlace.Rel = Where.RelType.EVENT_ALTERNATE;
            entry.Locations.Add(newPlace);
            return entry;
        }
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>creates a new, in memory atom entry</summary> 
        /// <returns>the new AtomEntry </returns>
        //////////////////////////////////////////////////////////////////////
        public static ContactEntry CreateContactEntry(int iCount)
        {
            ContactEntry entry = new ContactEntry();
            // some unicode chars
            Char[] chars = new Char[] {
                                          '\u0023', // #
                                          '\u0025', // %
                                          '\u03a0', // Pi
                                          '\u03a3',  // Sigma
                                          '\u03d1', // beta
            };

            // if unicode needs to be disabled for testing, just uncomment this line
            // chars = new Char[] { 'a', 'b', 'c', 'd', 'e'}; 



            AtomPerson author = new AtomPerson(AtomPersonType.Author);
            author.Name = "John Doe" + chars[0] + chars[1] + chars[2] + chars[3];
            author.Email = "*****@*****.**";
            entry.Authors.Add(author);

            entry.Content.Content = "this is the default note for a contact entry";
            entry.Published = new DateTime(2001, 11, 20, 22, 30, 0);
            entry.Title.Text = "This is a contact number: " + iCount;
            entry.Updated = DateTime.Now;

            // add an email.

            EMail email = new EMail("*****@*****.**" + Guid.NewGuid().ToString());
            email.Primary = true;
            email.Rel = ContactsRelationships.IsWork;

            entry.Emails.Add(email);

            email = new EMail("*****@*****.**" + Guid.NewGuid().ToString());
            email.Label = "some email";
            entry.Emails.Add(email);

            IMAddress im = new IMAddress("*****@*****.**");
            im.Primary = true;
            im.Rel = ContactsRelationships.IsWork;

            entry.IMs.Add(im);
            im = new IMAddress("*****@*****.**");
            im.Rel = ContactsRelationships.IsHome;

            PhoneNumber p = new PhoneNumber("123-3453457");
            p.Primary = true;
            p.Rel = ContactsRelationships.IsWork;
            entry.Phonenumbers.Add(p);

            p = new PhoneNumber("123-3334445");
            p.Label = "some other thing";
            entry.Phonenumbers.Add(p);

            PostalAddress pa = new PostalAddress("This is the address");
            pa.Primary = true;
            pa.Rel = ContactsRelationships.IsHome;
            entry.PostalAddresses.Add(pa);

            Organization org = new Organization();
            org.Name = "This Test Org.Com";
            org.Title = "Junior guy";
            org.Label = "volunteer stuff";

            entry.Organizations.Add(org);


            return entry;
        }
Example #11
0
 /// <summary>standard typed accessor method </summary> 
 public int Add( AtomPerson value )  
 {
     return( List.Add( value ) );
 }
 public void UriTest()
 {
     AtomPerson target = new AtomPerson(); // TODO: Initialize to an appropriate value
     AtomUri expected = new AtomUri("http://www.test.com/");
     AtomUri actual;
     target.Uri = expected;
     actual = target.Uri;
     Assert.AreEqual(expected, actual);
 }
 public void AtomPersonConstructorTest()
 {
     string name = "TestValue"; 
     AtomPerson target = new AtomPerson(AtomPersonType.Contributor, name);
     Assert.AreEqual(target.Name, name);
 }
 public void EmailTest()
 {
     AtomPerson target = new AtomPerson(); // TODO: Initialize to an appropriate value
     string expected = "TestValue";            
     string actual;
     target.Email = expected;
     actual = target.Email;
     Assert.AreEqual(expected, actual);
 }
Example #15
0
 /// <summary>standard typed accessor method </summary> 
 public bool Contains( AtomPerson value )  
 {
     // If value is not of type AtomPerson, this will return false.
     return( List.Contains( value ) );
 }
Example #16
0
 /// <summary>standard typed accessor method </summary> 
 public void Remove( AtomPerson value )  
 {
     List.Remove( value );
 }
Example #17
0
 /// <summary>standard typed accessor method </summary> 
 public void Insert( int index, AtomPerson value )  
 {
     List.Insert( index, value );
 }