public void AtomTextConstructConstructorTest2() { AtomTextConstruct target = new AtomTextConstruct(); Assert.IsNotNull(target); Assert.IsTrue(String.IsNullOrEmpty(target.Text)); }
public void AtomTextConstructConstructorTest() { string text = "TestValue"; // TODO: Initialize to an appropriate value AtomTextConstruct target = new AtomTextConstruct(AtomTextConstructElementType.Summary, text); Assert.AreEqual(target.Text, text); }
private void AssertSinglePostTestDocumentContentProperties( UnprocessedDocumentContent unprocessedDocument, AtomTextConstruct?Title = null, string Content = "<p>This is the test blog entry content.</p>", List <AtomCategory>?Categories = null, List <AtomLink>?Links = null ) { if (Title == null) { Title = new AtomTextConstruct("html", "Test Blog Entry Title"); } if (Categories == null) { Categories = new List <AtomCategory>(); } if (Links == null) { Links = new List <AtomLink>() { new AtomLink(Href: "https://example.com/testblog/test-blog-entry-title", Rel: "alternate", Type: "text/html"), new AtomLink(Href: "https://example.com/testblog/test-blog-entry-title/#comments", Rel: "replies", Type: "text/html"), new AtomLink(Href: "https://example.com/testblog/test-blog-entry-title/feed/atom/", Rel: "replies", Type: "application/atom+xml"), } } ; Assert.IsTrue(unprocessedDocument is UnprocessedAtomContent); var content = (unprocessedDocument as UnprocessedAtomContent) !; Assert.AreEqual(Title, content.Title); Assert.AreEqual(Content, content.Content); Assert.IsTrue(Enumerable.SequenceEqual(Categories !, content.Categories)); Assert.IsTrue(Enumerable.SequenceEqual(Links !, content.Links)); }
/// <summary> /// Initializes a new instance of the <see cref="AtomWorkspace"/> class using the supplied <see cref="AtomTextConstruct"/>. /// </summary> /// <param name="title">A <see cref="AtomTextConstruct"/> object that represents information that conveys a human-readable title for the workspace.</param> /// <exception cref="ArgumentNullException">The <paramref name="title"/> is a null reference (Nothing in Visual Basic).</exception> public AtomWorkspace(AtomTextConstruct title) { //------------------------------------------------------------ // Initialize class state using guarded property //------------------------------------------------------------ this.Title = title; }
internal virtual AtomBase CreateAtomBase() { AtomTextConstruct entry = new AtomTextConstruct(); entry.Text = "test"; return(entry); }
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); }
//============================================================ // CLASS SUMMARY //============================================================ /// <summary> /// Provides example code for the AtomTextConstruct class. /// </summary> public static void ClassExample() { #region AtomTextConstruct 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); // Provide summary as entity escaped html AtomTextConstruct summary = new AtomTextConstruct(); summary.Content = "AT&amp;T bought <b>by SBC</b>!"; summary.TextType = AtomTextConstructType.Html; entry.Summary = summary; feed.AddEntry(entry); #endregion }
/// <summary> /// Initializes a new instance of the <see cref="AtomEntryResource"/> class using the supplied <see cref="AtomId"/>, <see cref="AtomTextConstruct"/>, and <see cref="DateTime"/>. /// </summary> /// <param name="id">A <see cref="AtomId"/> object that represents a permanent, universally unique identifier for this entry.</param> /// <param name="title">A <see cref="AtomTextConstruct"/> object that represents information that conveys a human-readable title for this entry.</param> /// <param name="updatedOn"> /// A <see cref="DateTime"/> that indicates the most recent instant in time when this entry was modified in a way the publisher considers significant. /// The <see cref="DateTime"/> should be provided in Coordinated Universal Time (UTC). /// </param> /// <param name="editedOn"> /// A <see cref="DateTime"/> that indicates the most recent instant in time when this entry was edited. /// The <see cref="DateTime"/> should be provided in Coordinated Universal Time (UTC). /// </param> /// <param name="isDraft">A value indicating if client has requested to control the visibility of the entry.</param> /// <exception cref="ArgumentNullException">The <paramref name="id"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="title"/> is a null reference (Nothing in Visual Basic).</exception> public AtomEntryResource(AtomId id, AtomTextConstruct title, DateTime updatedOn, DateTime editedOn, bool isDraft) : this(id, title, updatedOn, editedOn) { //------------------------------------------------------------ // Initialize class state using properties //------------------------------------------------------------ this.IsDraft = isDraft; }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>compares 2 text construct objects</summary> /// <param name="theOne">the One</param> /// <param name="theOther">the Other</param> /// <returns>true if identical </returns> ////////////////////////////////////////////////////////////////////// public static bool IsTextConstructIdentical(AtomTextConstruct theOne, AtomTextConstruct theOther) { if (theOne == null && theOther == null) { return(true); } if (!ObjectModelHelper.IsBaseIdentical(theOne, theOther)) { return(false); } if (theOne.Type != theOther.Type) { return(false); } if (String.Compare(theOne.Text, theOther.Text) != 0) { return(false); } if (String.Compare(theOne.XmlName, theOther.XmlName) != 0) { return(false); } return(true); }
public AtomEntry(Uri id, AtomTextConstruct title, DateTime updated) : base(id, title, updated) { _content = null; _published = null; _source = null; _summary = null; }
/// <summary> /// Loads this <see cref="AtomWorkspace"/> using the supplied <see cref="XPathNavigator"/>. /// </summary> /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param> /// <returns><b>true</b> if the <see cref="AtomWorkspace"/> was initialized using the supplied <paramref name="source"/>, otherwise <b>false</b>.</returns> /// <remarks> /// This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents a <see cref="AtomWorkspace"/>. /// </remarks> /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception> public bool Load(XPathNavigator source) { //------------------------------------------------------------ // Local members //------------------------------------------------------------ bool wasLoaded = false; //------------------------------------------------------------ // Validate parameter //------------------------------------------------------------ Guard.ArgumentNotNull(source, "source"); //------------------------------------------------------------ // Initialize XML namespace resolver //------------------------------------------------------------ XmlNamespaceManager manager = AtomUtility.CreateNamespaceManager(source.NameTable); //------------------------------------------------------------ // Attempt to extract common attributes information //------------------------------------------------------------ if (AtomUtility.FillCommonObjectAttributes(this, source)) { wasLoaded = true; } //------------------------------------------------------------ // Attempt to extract syndication information //------------------------------------------------------------ if (source.HasChildren) { XPathNavigator titleNavigator = source.SelectSingleNode("atom:title", manager); XPathNodeIterator collectionIterator = source.Select("app:collection", manager); if (titleNavigator != null) { this.Title = new AtomTextConstruct(); if (this.Title.Load(titleNavigator)) { wasLoaded = true; } } if (collectionIterator != null && collectionIterator.Count > 0) { while (collectionIterator.MoveNext()) { AtomMemberResources collection = new AtomMemberResources(); if (collection.Load(collectionIterator.Current)) { this.AddCollection(collection); wasLoaded = true; } } } } return(wasLoaded); }
/// <summary> /// Get the Text of possibly null AtomTextConstruct /// </summary> /// <param name="textConstruct">The Google AtomTextConstruct</param> /// <returns>The value or empty string if the textConstruct or it's Text was null</returns> public static string SafeGetText(AtomTextConstruct textConstruct) { if (textConstruct == null) { return(string.Empty); } return(textConstruct.Text ?? string.Empty); }
/// <summary> /// Creates a <see cref="AtomTextConstruct"/> 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="AtomTextConstruct"/> 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 Content 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 AtomTextConstruct CreateTextContent(XPathNavigator source, XmlNamespaceManager manager, SyndicationResourceLoadSettings settings) { AtomTextConstruct content = new AtomTextConstruct(); Guard.ArgumentNotNull(source, "source"); Guard.ArgumentNotNull(manager, "manager"); Guard.ArgumentNotNull(settings, "settings"); AtomUtility.FillCommonObjectAttributes(content, source); if (source.HasAttributes) { string modeAttribute = source.GetAttribute("mode", String.Empty); if (!String.IsNullOrEmpty(modeAttribute)) { if (String.Compare(modeAttribute, "base64", StringComparison.OrdinalIgnoreCase) == 0) { content.TextType = AtomTextConstructType.Text; } else if (String.Compare(modeAttribute, "escaped", StringComparison.OrdinalIgnoreCase) == 0) { content.TextType = AtomTextConstructType.Html; } else if (String.Compare(modeAttribute, "xml", StringComparison.OrdinalIgnoreCase) == 0) { content.TextType = AtomTextConstructType.Xhtml; } else { content.TextType = AtomTextConstructType.Text; } } } if (content.TextType == AtomTextConstructType.Xhtml) { XPathNavigator xhtmlDivNavigator = source.SelectSingleNode("xhtml:div", manager); if (xhtmlDivNavigator != null && !String.IsNullOrEmpty(xhtmlDivNavigator.Value)) { content.Content = xhtmlDivNavigator.Value; } else if (!String.IsNullOrEmpty(source.Value)) { content.Content = source.Value; } } else if (!String.IsNullOrEmpty(source.Value)) { content.Content = source.Value; } SyndicationExtensionAdapter adapter = new SyndicationExtensionAdapter(source, settings); adapter.Fill(content, manager); return(content); }
public void TextTest() { AtomTextConstruct target = new AtomTextConstruct(); // TODO: Initialize to an appropriate value string expected = "TestValue"; string actual; target.Text = expected; actual = target.Text; Assert.AreEqual(expected, actual); }
/// <summary> /// Initializes a new instance of the <see cref="AtomWorkspace"/> class using the supplied <see cref="AtomTextConstruct"/> and <see cref="Collection{AtomMemberResources}"/>. /// </summary> /// <param name="title">A <see cref="AtomTextConstruct"/> object that represents information that conveys a human-readable title for the workspace.</param> /// <param name="collections"></param> /// <exception cref="ArgumentNullException">The <paramref name="title"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="collections"/> is a null reference (Nothing in Visual Basic).</exception> public AtomWorkspace(AtomTextConstruct title, Collection <AtomMemberResources> collections) { this.Title = title; Guard.ArgumentNotNull(collections, "collections"); foreach (AtomMemberResources collection in collections) { this.AddCollection(collection); } }
public void TypeTest() { AtomTextConstruct target = new AtomTextConstruct(); // TODO: Initialize to an appropriate value AtomTextConstructType expected = AtomTextConstructType.xhtml; AtomTextConstructType actual; target.Type = expected; actual = target.Type; Assert.AreEqual(expected, actual); }
public void PropertyGettersAndSettersTest() { AtomTextConstruct title = new AtomTextConstruct(); AtomWorkspaceMetadata workspace = new AtomWorkspaceMetadata() { Title = title, }; this.Assert.AreSame(title, workspace.Title, "Expected reference equal values for property 'Title'."); }
public void XmlNameTest() { AtomTextConstruct target = new AtomTextConstruct(AtomTextConstructElementType.Rights); Assert.AreEqual(target.XmlName, AtomParserNameTable.XmlRightsElement); target = new AtomTextConstruct(AtomTextConstructElementType.Subtitle); Assert.AreEqual(target.XmlName, AtomParserNameTable.XmlSubtitleElement); target = new AtomTextConstruct(AtomTextConstructElementType.Title); Assert.AreEqual(target.XmlName, AtomParserNameTable.XmlTitleElement); target = new AtomTextConstruct(AtomTextConstructElementType.Summary); Assert.AreEqual(target.XmlName, AtomParserNameTable.XmlSummaryElement); }
/// <summary> /// Initializes a new instance of the <see cref="AtomWorkspace"/> class using the supplied <see cref="AtomTextConstruct"/> and <see cref="Collection{AtomMemberResources}"/>. /// </summary> /// <param name="title">A <see cref="AtomTextConstruct"/> object that represents information that conveys a human-readable title for the workspace.</param> /// <param name="collections"></param> /// <exception cref="ArgumentNullException">The <paramref name="title"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="collections"/> is a null reference (Nothing in Visual Basic).</exception> public AtomWorkspace(AtomTextConstruct title, Collection <AtomMemberResources> collections) { //------------------------------------------------------------ // Initialize class state using guarded property //------------------------------------------------------------ this.Title = title; Guard.ArgumentNotNull(collections, "collections"); foreach (AtomMemberResources collection in collections) { this.AddCollection(collection); } }
public AtomSource() : base() { _id = null; _title = null; _subtitle = null; _updated = null; _authors = null; _contributors = null; _links = null; _categories = null; _generator = null; _icon = null; _rights = null; }
public AtomSource(AtomFeed sourceFeed) : base(sourceFeed.XmlBase, sourceFeed.XmlLang) { _id = sourceFeed.ID; _title = sourceFeed.Title; _subtitle = sourceFeed.Subtitle; _updated = sourceFeed.Updated; _authors = sourceFeed.Authors; _contributors = sourceFeed.Contributors; _links = sourceFeed.Links; _categories = sourceFeed.Categories; _generator = sourceFeed.Generator; _icon = sourceFeed.Icon; _rights = sourceFeed.Rights; }
public void PropertyGettersAndSettersTest() { AtomTextConstruct title = new AtomTextConstruct(); string accept = "mime/type"; AtomCategoriesMetadata categories = new AtomCategoriesMetadata(); AtomResourceCollectionMetadata resourceCollection = new AtomResourceCollectionMetadata() { Title = title, Accept = accept, Categories = categories }; this.Assert.AreSame(title, resourceCollection.Title, "Expected reference equal values for property 'Title'."); this.Assert.AreSame(accept, resourceCollection.Accept, "Expected reference equal values for property 'Accept'."); this.Assert.AreSame(categories, resourceCollection.Categories, "Expected reference equal values for property 'Categories'."); }
internal void WriteServiceDocument(DataServiceProviderWrapper provider) { ODataWorkspace defaultWorkspace = new ODataWorkspace { Collections = provider.GetResourceSets().Select <ResourceSetWrapper, ODataResourceCollectionInfo>(delegate(ResourceSetWrapper rs) { ODataResourceCollectionInfo info = new ODataResourceCollectionInfo { Url = new Uri(rs.Name, UriKind.RelativeOrAbsolute) }; AtomResourceCollectionMetadata annotation = new AtomResourceCollectionMetadata(); AtomTextConstruct construct = new AtomTextConstruct { Text = rs.Name }; annotation.Title = construct; info.SetAnnotation <AtomResourceCollectionMetadata>(annotation); return(info); }) }; this.writer.WriteServiceDocument(defaultWorkspace); }
/// <summary> /// Loads this <see cref="AtomWorkspace"/> using the supplied <see cref="XPathNavigator"/>. /// </summary> /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param> /// <returns><b>true</b> if the <see cref="AtomWorkspace"/> was initialized using the supplied <paramref name="source"/>, otherwise <b>false</b>.</returns> /// <remarks> /// This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents a <see cref="AtomWorkspace"/>. /// </remarks> /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception> public bool Load(XPathNavigator source) { bool wasLoaded = false; Guard.ArgumentNotNull(source, "source"); XmlNamespaceManager manager = AtomUtility.CreateNamespaceManager(source.NameTable); if (AtomUtility.FillCommonObjectAttributes(this, source)) { wasLoaded = true; } if (source.HasChildren) { XPathNavigator titleNavigator = source.SelectSingleNode("atom:title", manager); XPathNodeIterator collectionIterator = source.Select("app:collection", manager); if (titleNavigator != null) { this.Title = new AtomTextConstruct(); if (this.Title.Load(titleNavigator)) { wasLoaded = true; } } if (collectionIterator != null && collectionIterator.Count > 0) { while (collectionIterator.MoveNext()) { AtomMemberResources collection = new AtomMemberResources(); if (collection.Load(collectionIterator.Current)) { this.AddCollection(collection); wasLoaded = true; } } } } return(wasLoaded); }
public AtomDocument(Uri id, AtomTextConstruct title, DateTime updated) : base() { if (id == null) { throw new ArgumentNullException("", "id"); } if (title == null) { throw new ArgumentNullException("", "title"); } _id = id; _title = title; _updated = updated; _rights = null; _authors = null; _contributors = null; _categories = null; _links = null; }
/// <summary> /// Merges ATOM text values. /// </summary> /// <param name="customValue">The custom value.</param> /// <param name="epmValue">The EPM value.</param> /// <param name="propertyName">The name of the ATOM property which holds the text value, used for error reporting.</param> /// <returns>The merged ATOM text value.</returns> private static AtomTextConstruct MergeAtomTextValue(AtomTextConstruct customValue, AtomTextConstruct epmValue, string propertyName) { AtomTextConstruct simpleMergeResult; if (TryMergeIfNull(customValue, epmValue, out simpleMergeResult)) { return(simpleMergeResult); } if (customValue.Kind != epmValue.Kind) { throw new ODataException(Strings.ODataAtomMetadataEpmMerge_TextKindConflict(propertyName, customValue.Kind.ToString(), epmValue.Kind.ToString())); } if (!string.Equals(customValue.Text, epmValue.Text, StringComparison.Ordinal)) { throw new ODataException(Strings.ODataAtomMetadataEpmMerge_TextValueConflict(propertyName, customValue.Text, epmValue.Text)); } return(epmValue); }
/// <summary> /// Writes an Xml element with the specified primitive value as content. /// </summary> /// <param name="writer">The Xml writer to write to.</param> /// <param name="prefix">The prefix for the element's namespace.</param> /// <param name="localName">The local name of the element.</param> /// <param name="ns">The namespace of the element.</param> /// <param name="textConstruct">The <see cref="AtomTextConstruct"/> value to be used as element content.</param> internal static void WriteTextConstruct(XmlWriter writer, string prefix, string localName, string ns, AtomTextConstruct textConstruct) { DebugUtils.CheckNoExternalCallers(); Debug.Assert(writer != null, "writer != null"); Debug.Assert(prefix != null, "prefix != null"); Debug.Assert(!string.IsNullOrEmpty(localName), "!string.IsNullOrEmpty(localName)"); Debug.Assert(!string.IsNullOrEmpty(ns), "!string.IsNullOrEmpty(ns)"); writer.WriteStartElement(prefix, localName, ns); if (textConstruct != null) { AtomTextConstructKind textKind = textConstruct.Kind; writer.WriteAttributeString(AtomConstants.AtomTypeAttributeName, AtomValueUtils.ToString(textConstruct.Kind)); string textValue = textConstruct.Text ?? string.Empty; if (textKind == AtomTextConstructKind.Xhtml) { writer.WriteRaw(textValue); } else { writer.WriteString(textValue); } } writer.WriteEndElement(); }
/// <summary> /// Initializes a new instance of the <see cref="AtomEntryResource"/> class using the supplied <see cref="AtomId"/>, <see cref="AtomTextConstruct"/>, and <see cref="DateTime"/>. /// </summary> /// <param name="id">A <see cref="AtomId"/> object that represents a permanent, universally unique identifier for this entry.</param> /// <param name="title">A <see cref="AtomTextConstruct"/> object that represents information that conveys a human-readable title for this entry.</param> /// <param name="updatedOn"> /// A <see cref="DateTime"/> that indicates the most recent instant in time when this entry was modified in a way the publisher considers significant. /// The <see cref="DateTime"/> should be provided in Coordinated Universal Time (UTC). /// </param> /// <exception cref="ArgumentNullException">The <paramref name="id"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="title"/> is a null reference (Nothing in Visual Basic).</exception> public AtomEntryResource(AtomId id, AtomTextConstruct title, DateTime updatedOn) : base(id, title, updatedOn) { //------------------------------------------------------------ // Initialization handled by base class //------------------------------------------------------------ }
/// <summary> /// Initializes a new instance of the <see cref="AtomWorkspace"/> class using the supplied <see cref="AtomTextConstruct"/>. /// </summary> /// <param name="title">A <see cref="AtomTextConstruct"/> object that represents information that conveys a human-readable title for the workspace.</param> /// <exception cref="ArgumentNullException">The <paramref name="title"/> is a null reference (Nothing in Visual Basic).</exception> public AtomWorkspace(AtomTextConstruct title) { this.Title = title; }
/// <summary> /// Initializes a new instance of the <see cref="AtomMemberResources"/> class using the supplied <see cref="AtomTextConstruct"/>. /// </summary> /// <param name="href">A <see cref="Uri"/> that represents a Internationalized Resource Identifier (IRI) that identifies the location of the collection.</param> /// <param name="title">A <see cref="AtomTextConstruct"/> object that represents information that conveys a human-readable title for the collection.</param> /// <exception cref="ArgumentNullException">The <paramref name="href"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="title"/> is a null reference (Nothing in Visual Basic).</exception> public AtomMemberResources(Uri href, AtomTextConstruct title) : this() { this.Uri = href; this.Title = title; }
/// <summary> /// Visits an ATOM text construct. /// </summary> /// <param name="atomTextConstruct">The text construct to visit.</param> protected virtual void VisitAtomTextConstruct(AtomTextConstruct atomTextConstruct) { }
/// <summary> /// Visits an ATOM metadata object. /// </summary> /// <param name="atomMetadata"></param> protected virtual void VisitAtomMetadata(object atomMetadata) { if (atomMetadata == null) { return; } AtomCategoryMetadata atomCategoryMetadata = atomMetadata as AtomCategoryMetadata; if (atomCategoryMetadata != null) { this.VisitAtomCategoryMetadata(atomCategoryMetadata); return; } AtomEntryMetadata atomEntryMetadata = atomMetadata as AtomEntryMetadata; if (atomEntryMetadata != null) { this.VisitAtomEntryMetadata(atomEntryMetadata); return; } AtomFeedMetadata atomFeedMetadata = atomMetadata as AtomFeedMetadata; if (atomFeedMetadata != null) { this.VisitAtomFeedMetadata(atomFeedMetadata); return; } AtomGeneratorMetadata atomGeneratorMetadata = atomMetadata as AtomGeneratorMetadata; if (atomGeneratorMetadata != null) { this.VisitAtomGeneratorMetadata(atomGeneratorMetadata); return; } AtomLinkMetadata atomLinkMetadata = atomMetadata as AtomLinkMetadata; if (atomLinkMetadata != null) { this.VisitAtomLinkMetadata(atomLinkMetadata); return; } AtomPersonMetadata atomPersonMetadata = atomMetadata as AtomPersonMetadata; if (atomPersonMetadata != null) { this.VisitAtomPersonMetadata(atomPersonMetadata); return; } AtomResourceCollectionMetadata atomResourceCollectionMetadata = atomMetadata as AtomResourceCollectionMetadata; if (atomResourceCollectionMetadata != null) { this.VisitAtomResourceCollectionMetadata(atomResourceCollectionMetadata); return; } AtomStreamReferenceMetadata atomStreamReferenceMetadata = atomMetadata as AtomStreamReferenceMetadata; if (atomStreamReferenceMetadata != null) { this.VisitAtomStreamReferenceMetadata(atomStreamReferenceMetadata); return; } AtomTextConstruct atomTextConstruct = atomMetadata as AtomTextConstruct; if (atomTextConstruct != null) { this.VisitAtomTextConstruct(atomTextConstruct); return; } AtomWorkspaceMetadata atomWorkspaceMetadata = atomMetadata as AtomWorkspaceMetadata; if (atomWorkspaceMetadata != null) { this.VisitAtomWorkspaceMetadata(atomWorkspaceMetadata); return; } AtomCategoriesMetadata atomCategoriesMetadata = atomMetadata as AtomCategoriesMetadata; if (atomCategoriesMetadata != null) { this.VisitAtomCategoriesMetadata(atomCategoriesMetadata); return; } ExceptionUtilities.Assert(false, "Unrecognized ATOM metadata object {0} of type {1}.", atomMetadata.ToString(), atomMetadata.GetType().ToString()); }
/// <summary> /// Initializes a new instance of the <see cref="AtomEntryResource"/> class using the supplied <see cref="AtomId"/>, <see cref="AtomTextConstruct"/>, and <see cref="DateTime"/>. /// </summary> /// <param name="id">A <see cref="AtomId"/> object that represents a permanent, universally unique identifier for this entry.</param> /// <param name="title">A <see cref="AtomTextConstruct"/> object that represents information that conveys a human-readable title for this entry.</param> /// <param name="updatedOn"> /// A <see cref="DateTime"/> that indicates the most recent instant in time when this entry was modified in a way the publisher considers significant. /// The <see cref="DateTime"/> should be provided in Coordinated Universal Time (UTC). /// </param> /// <param name="editedOn"> /// A <see cref="DateTime"/> that indicates the most recent instant in time when this entry was edited. /// The <see cref="DateTime"/> should be provided in Coordinated Universal Time (UTC). /// </param> /// <param name="isDraft">A value indicating if client has requested to control the visibility of the entry.</param> /// <exception cref="ArgumentNullException">The <paramref name="id"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="title"/> is a null reference (Nothing in Visual Basic).</exception> public AtomEntryResource(AtomId id, AtomTextConstruct title, DateTime updatedOn, DateTime editedOn, bool isDraft) : this(id, title, updatedOn, editedOn) { this.IsDraft = isDraft; }
public SettingsFeed(Uri id, AtomTextConstruct title, DateTime updated) : base(id, title, updated) { }
public SettingsEntry(Uri id, AtomTextConstruct title, DateTime updated) : base(id, title, updated) { _type = null; }
/// <summary> /// Write the ATOM metadata for an entry /// </summary> /// <param name="writer">The Xml writer to write to.</param> /// <param name="baseUri">The base Uri of the document or null if none was specified.</param> /// <param name="entry">The entry for which to write the metadata.</param> /// <param name="epmEntryMetadata">The ATOM metadata for the entry which came from EPM.</param> internal static void WriteEntryMetadata(XmlWriter writer, Uri baseUri, ODataEntry entry, AtomEntryMetadata epmEntryMetadata) { DebugUtils.CheckNoExternalCallers(); Debug.Assert(writer != null, "writer != null"); // TODO, ckerer: implement the rule around authors (an entry has to have an author directly or in the <entry:source> unless the feed has an author). // currently we make all entries have an author. AtomEntryMetadata customEntryMetadata = entry.GetAnnotation <AtomEntryMetadata>(); AtomEntryMetadata entryMetadata = ODataAtomWriterMetadataEpmMergeUtils.MergeCustomAndEpmEntryMetadata(customEntryMetadata, epmEntryMetadata); if (entryMetadata == null) { // write all required metadata elements with default content // <atom:title></atom:title> ODataAtomWriterUtils.WriteEmptyElement(writer, AtomConstants.AtomNamespacePrefix, AtomConstants.AtomTitleElementName, AtomConstants.AtomNamespace); // <atom:updated>dateTimeOffset</atom:updated> // NOTE: the <updated> element is required and if not specified the best we can do is to create a default // one with the current date/time. ODataAtomWriterUtils.WriteElementWithTextContent(writer, AtomConstants.AtomNamespacePrefix, AtomConstants.AtomUpdatedElementName, AtomConstants.AtomNamespace, ODataAtomConvert.ToString(DateTimeOffset.UtcNow)); WriteEmptyAuthor(writer); } else { // <atom:title>text</atom:title> // NOTE: writes an empty element even if no title was specified since the title is required ODataAtomWriterMetadataUtils.WriteTextConstruct(writer, AtomConstants.AtomNamespacePrefix, AtomConstants.AtomTitleElementName, AtomConstants.AtomNamespace, entryMetadata.Title); AtomTextConstruct summary = entryMetadata.Summary; if (summary != null) { // <atom:summary>text</atom:summary> ODataAtomWriterMetadataUtils.WriteTextConstruct(writer, AtomConstants.AtomNamespacePrefix, AtomConstants.AtomSummaryElementName, AtomConstants.AtomNamespace, summary); } DateTimeOffset?published = entryMetadata.Published; if (published.HasValue) { // <atom:published>dateTimeOffset</atom:published> ODataAtomWriterUtils.WriteElementWithTextContent(writer, AtomConstants.AtomNamespacePrefix, AtomConstants.AtomPublishedElementName, AtomConstants.AtomNamespace, ODataAtomConvert.ToString(published.Value)); } // <atom:updated>date</atom:updated> // NOTE: the <updated> element is required and if not specified the best we can do is to create a default // one with the current date/time. DateTimeOffset updated = entryMetadata.Updated.HasValue ? entryMetadata.Updated.Value : DateTimeOffset.UtcNow; ODataAtomWriterUtils.WriteElementWithTextContent( writer, AtomConstants.AtomNamespacePrefix, AtomConstants.AtomUpdatedElementName, AtomConstants.AtomNamespace, ODataAtomConvert.ToString(updated)); bool wroteAuthor = false; IEnumerable <AtomPersonMetadata> authors = entryMetadata.Authors; if (authors != null) { foreach (AtomPersonMetadata author in authors) { if (author == null) { throw new ODataException(Strings.ODataAtomWriterMetadataUtils_AuthorMetadataMustNotContainNull); } // <atom:author>author data</atom:author> writer.WriteStartElement(AtomConstants.AtomNamespacePrefix, AtomConstants.AtomAuthorElementName, AtomConstants.AtomNamespace); WritePersonMetadata(writer, baseUri, author); writer.WriteEndElement(); wroteAuthor = true; } } if (!wroteAuthor) { // write empty authors since they are required WriteEmptyAuthor(writer); } IEnumerable <AtomPersonMetadata> contributors = entryMetadata.Contributors; if (contributors != null) { foreach (AtomPersonMetadata contributor in contributors) { if (contributor == null) { throw new ODataException(Strings.ODataAtomWriterMetadataUtils_ContributorMetadataMustNotContainNull); } // <atom:contributor>contributor data</atom:contributor> writer.WriteStartElement(AtomConstants.AtomNamespacePrefix, AtomConstants.AtomContributorElementName, AtomConstants.AtomNamespace); WritePersonMetadata(writer, baseUri, contributor); writer.WriteEndElement(); } } IEnumerable <AtomLinkMetadata> links = entryMetadata.Links; if (links != null) { foreach (AtomLinkMetadata link in links) { if (link == null) { throw new ODataException(Strings.ODataAtomWriterMetadataUtils_LinkMetadataMustNotContainNull); } // <atom:link>...</atom:link> WriteAtomLinkMetadata(writer, baseUri, link); } } IEnumerable <AtomCategoryMetadata> categories = entryMetadata.Categories; if (categories != null) { foreach (AtomCategoryMetadata category in categories) { if (category == null) { throw new ODataException(Strings.ODataAtomWriterMetadataUtils_CategoryMetadataMustNotContainNull); } // <atom:category term="..." scheme="..." label="..."></atom:category> WriteCategory(writer, category); } } if (entryMetadata.Rights != null) { // <atom:rights>rights</atom:rights> ODataAtomWriterMetadataUtils.WriteTextConstruct(writer, AtomConstants.AtomNamespacePrefix, AtomConstants.AtomRightsElementName, AtomConstants.AtomNamespace, entryMetadata.Rights); } Uri icon = entryMetadata.Icon; if (icon != null) { // <atom:icon>Uri</atom:icon> ODataAtomWriterUtils.WriteElementWithTextContent( writer, AtomConstants.AtomNamespacePrefix, AtomConstants.AtomIconElementName, AtomConstants.AtomNamespace, AtomUtils.ToUrlAttributeValue(icon, baseUri)); } AtomFeedMetadata source = entryMetadata.Source; if (source != null) { // <atom:source> writer.WriteStartElement(AtomConstants.AtomNamespacePrefix, AtomConstants.AtomSourceElementName, AtomConstants.AtomNamespace); WriteFeedMetadata(writer, baseUri, source, null); // </atom:source> writer.WriteEndElement(); } } }
/// <summary> /// Initializes a new instance of the <see cref="AtomEntryResource"/> class using the supplied <see cref="AtomId"/>, <see cref="AtomTextConstruct"/>, and <see cref="DateTime"/>. /// </summary> /// <param name="id">A <see cref="AtomId"/> object that represents a permanent, universally unique identifier for this entry.</param> /// <param name="title">A <see cref="AtomTextConstruct"/> object that represents information that conveys a human-readable title for this entry.</param> /// <param name="updatedOn"> /// A <see cref="DateTime"/> that indicates the most recent instant in time when this entry was modified in a way the publisher considers significant. /// The <see cref="DateTime"/> should be provided in Coordinated Universal Time (UTC). /// </param> /// <param name="editedOn"> /// A <see cref="DateTime"/> that indicates the most recent instant in time when this entry was edited. /// The <see cref="DateTime"/> should be provided in Coordinated Universal Time (UTC). /// </param> /// <exception cref="ArgumentNullException">The <paramref name="id"/> is a null reference (Nothing in Visual Basic).</exception> /// <exception cref="ArgumentNullException">The <paramref name="title"/> is a null reference (Nothing in Visual Basic).</exception> public AtomEntryResource(AtomId id, AtomTextConstruct title, DateTime updatedOn, DateTime editedOn) : this(id, title, updatedOn) { this.EditedOn = editedOn; }