/// <summary>
 ///
 /// </summary>
 /// <param name="content"></param>
 /// <param name="type"></param>
 /// <param name="src"></param>
 public AtomContent(string content, AtomTextType type, string src)
 {
     this.Content = content;
     this.Type    = type;
     this.Src     = src;
     this.Modules = new SyndicationModuleCollection();
 }
Exemple #2
0
 /// <summary>
 /// This is the feed subtitle.
 /// </summary>
 public void AtomContentSet(AtomTextType type, string text)
 {
     AtomContentSet(type, text, null, null);
 }
Exemple #3
0
 public virtual void AtomSummarySet(AtomTextType type, string text,
     string baseUri, string lang)
 {
     AtomTextConstructSet("summary", type, text, baseUri, lang);
 }
Exemple #4
0
 ///// <summary>
 ///// This is the feed subtitle.
 ///// </summary>
 //public virtual void AtomSourceSet()
 //{
 //    throw new NotSupportedException();
 //}
 #endregion
 #region AtomSummarySet
 /// <summary>
 /// This is the feed subtitle.
 /// </summary>
 public void AtomSummarySet(AtomTextType type, string text)
 {
     AtomSummarySet(type, text, null, null);
 }
    /// <summary>Sets the <see cref="AtomTextNode.Text"/> of this node, and sets the <see cref="AtomTextNode.Type"/> of this node to <see cref="AtomTextType.Text"/>.</summary>
    /// <param name="text">A <see cref="string"/> representing the text to set.</param>
    /// <param name="type">An <see cref="AtomTextType"/> representing the type of text.</param>
    /// <exception cref="ArgumentNullException"><paramref name="text"/> is null.</exception>
    /// <exception cref="ArgumentException"><paramref name="text"/> is an empty <see cref="string"/>, or <paramref name="type"/> is "xhtml" and <paramref name="text"/> is not a valid XHTML element.</exception>
    /// <exception cref="InvalidOperationException"><paramref name="type"/> is "xhtml" and <paramref name="text"/> is not a valid XHTML div element.</exception>
    public void SetText(string text, AtomTextType type)
    {
      if(text == null) throw new ArgumentNullException("text");
      if(text == "") throw new ArgumentException(Errors.EmptyString, "text");

      if(type == AtomTextType.Xhtml)
      {
        XElement div = null;
        try { div = XElement.Parse(text); }
        catch(Exception) { throw new ArgumentException(Errors.NotAnElement, "text"); }
        if(div.Name != XhtmlNamespace + "div") throw new InvalidOperationException(Errors.NotAnXhtmlDiv);
        this.Element.ReplaceNodes(div);
      }
      else
        this.Element.SetValue(text);

      this.Element.SetAttributeValue("type", type == AtomTextType.None ? null : type.ToString().ToLower());
    }
 /// <summary>Initializes a new instance of the <see cref="AtomTextNode"/> class with the specified text and type.</summary>
 /// <param name="text">A <see cref="string"/> representing the text.</param>
 /// <param name="type">An <see cref="AtomTextType"/> representing the type of text.</param>
 protected AtomTextNode(string text, AtomTextType type)
 {
   this.SetText(text, type);
 }
Exemple #7
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="elementName"></param>
        /// <param name="type"></param>
        /// <param name="text"></param>
        /// <param name="baseUri"></param>
        /// <param name="lang"></param>
        /// <remarks>
        /// atomPlainTextConstruct =
        ///   atomCommonAttributes,
        ///   attribute type { "text" | "html" }?,
        ///   text
        ///
        /// atomXHTMLTextConstruct =
        ///   atomCommonAttributes,
        ///   attribute type { "xhtml" },
        ///   xhtmlDiv
        ///
        /// atomTextConstruct = atomPlainTextConstruct | atomXHTMLTextConstruct
        /// </remarks>
        protected void TextConstructWrite(XmlWriter writer, string elementName,
            AtomTextType type, string text,
            string baseUri, string lang)
        {
            writer.WriteStartElement(elementName, "http://www.w3.org/2005/Atom");

            CommonAttributesWrite(writer, baseUri, lang);

            switch (type)
            {
                case AtomTextType.Text:
                case AtomTextType.Html:
                    writer.WriteAttributeString("type", 
                        (string)((type==AtomTextType.Text)?"text":"html"));
                    writer.WriteString(text);
                    break;
                case AtomTextType.Xhtml:
                    writer.WriteAttributeString("type", "xhtml");
                    writer.WriteRaw(text);
                    break;
            }

            writer.WriteEndElement();
        }
Exemple #8
0
 public AtomText(string text, AtomTextType type)
 {
     this.Text = text;
     this.Type = type;
 }
Exemple #9
0
 protected virtual bool AtomTextConstructSet(string elementName,
     AtomTextType type, string text,
     string baseUri, string lang)
 {
     return AtomTextConstructSet(elementName, type, text, baseUri, lang, false);
 }
Exemple #10
0
 protected virtual bool AtomTextConstructSet(string elementName,
     AtomTextType type, string text, string baseUri, string lang, bool append)
 {
     XmlDocumentFragment frag = CreateFragment(
         delegate(XmlWriter writer)
         {
             TextConstructWrite( writer, elementName, type, text, baseUri, lang);
         });
     return FragmentSet(XPSc("r", elementName), append, frag);
 }
Exemple #11
0
 public void AtomTitleSet(AtomTextType type, string text,
     string baseUri, string lang)
 {
     AtomTextConstructSet("title", type, text, baseUri, lang);
 }
Exemple #12
0
 public void AtomTitleSet(AtomTextType type, string text)
 {
     AtomTitleSet(type, text, null, null);
 }
 /// <summary>Initializes a new instance of the <see cref="AtomSummary"/> class with the specified text and type.</summary>
 /// <param name="text">A <see cref="string"/> representing the text.</param>
 /// <param name="type">An <see cref="AtomTextType"/> representing the type of text.</param>
 public AtomSummary(string text, AtomTextType type) : base(text, type) { }
Exemple #14
0
 public virtual void AtomContentSet(AtomTextType type, string text,
     string baseUri, string lang)
 {
     AtomTextConstructSet("content", type, text, baseUri, lang);
 }
 /// <summary>Initializes a new instance of the <see cref="AtomSubtitle"/> class with the specified text and type.</summary>
 /// <param name="text">A <see cref="string"/> representing the text.</param>
 /// <param name="type">An <see cref="AtomTextType"/> representing the type of text.</param>
 public AtomSubtitle(string text, AtomTextType type) : base(text, type) { }
Exemple #16
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="elementName"></param>
        /// <param name="type"></param>
        /// <param name="text"></param>
        /// <param name="baseUri"></param>
        /// <param name="lang"></param>
        /// <remarks>
        /// atomInlineTextContent =
        ///   element atom:content {
        ///      atomCommonAttributes,
        ///      attribute type { "text" | "html" }?,
        ///      (text)*
        ///   }
        ///
        /// atomInlineXHTMLContent =
        ///   element atom:content {
        ///      atomCommonAttributes,
        ///      attribute type { "xhtml" },
        ///      xhtmlDiv
        ///   }
        ///
        /// atomInlineOtherContent =
        ///   element atom:content {
        ///      atomCommonAttributes,
        ///      attribute type { atomMediaType }?,
        ///      (text|anyElement)*
        ///   }
        ///
        /// atomOutOfLineContent =
        ///   element atom:content {
        ///      atomCommonAttributes,
        ///      attribute type { atomMediaType }?,
        ///      attribute src { atomUri },
        ///      empty
        ///   }
        ///
        /// atomContent = atomInlineTextContent
        ///  | atomInlineXHTMLContent
        ///  | atomInlineOtherContent
        ///  | atomOutOfLineContent
        /// </remarks>
        protected void ContentConstructWrite(XmlWriter writer, 
            AtomTextType type, string text,
            string baseUri, string lang)
        {
            writer.WriteStartElement("content");

            CommonAttributesWrite(writer, baseUri, lang);

            switch (type)
            {
                case AtomTextType.Text:
                case AtomTextType.Html:
                    writer.WriteAttributeString("type",
                        (string)((type == AtomTextType.Text) ? "text" : "html"));
                    writer.WriteString(text);
                    break;
                case AtomTextType.Xhtml:
                    writer.WriteAttributeString("type", "xhtml");
                    writer.WriteRaw(text);
                    break;
            }

            writer.WriteEndElement();
        }
 /// <summary>Initializes a new instance of the <see cref="AtomRights"/> class with the specified text and type.</summary>
 /// <param name="text">A <see cref="string"/> representing the text.</param>
 /// <param name="type">An <see cref="AtomTextType"/> representing the type of text.</param>
 public AtomRights(string text, AtomTextType type) : base(text, type) { }