//============================================================ // CLASS SUMMARY //============================================================ /// <summary> /// Provides example code for the AtomSource class. /// </summary> public static void ClassExample() { #region AtomSource 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")); feed.Authors.Add(new AtomPersonConstruct("John Doe")); 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."); // Entry was copied from another feed, so preserve source meta-data AtomSource source = new AtomSource(); source.Id = new AtomId(new Uri("http://example2.org/")); source.Title = new AtomTextConstruct("Fourty-Two"); source.UpdatedOn = new DateTime(2003, 11, 13, 18, 30, 2); source.Rights = new AtomTextConstruct("© 2003 Example, Inc."); entry.Source = source; feed.AddEntry(entry); #endregion }
/// <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); } AtomSource value = obj as AtomSource; if (value != null) { int result = AtomFeed.CompareSequence(this.Authors, value.Authors); result = result | AtomFeed.CompareSequence(this.Categories, value.Categories); result = result | AtomFeed.CompareSequence(this.Contributors, value.Contributors); if (this.Generator != null) { result = result | this.Generator.CompareTo(value.Generator); } else if (value.Generator != null) { result = result | -1; } if (this.Icon != null) { result = result | this.Icon.CompareTo(value.Icon); } else if (value.Icon != null) { result = result | -1; } if (this.Id != null) { result = result | this.Id.CompareTo(value.Id); } else if (value.Id != null) { result = result | -1; } result = result | AtomFeed.CompareSequence(this.Links, value.Links); if (this.Logo != null) { result = result | this.Logo.CompareTo(value.Logo); } else if (value.Logo != null) { result = result | -1; } if (this.Rights != null) { result = result | this.Rights.CompareTo(value.Rights); } else if (value.Rights != null) { result = result | -1; } if (this.Subtitle != null) { result = result | this.Subtitle.CompareTo(value.Subtitle); } else if (value.Subtitle != null) { result = result | -1; } if (this.Title != null) { result = result | this.Title.CompareTo(value.Title); } else if (value.Title != null) { result = result | -1; } result = result | this.UpdatedOn.CompareTo(value.UpdatedOn); result = result | AtomUtility.CompareCommonObjectAttributes(this, value); 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"); } }