TextSyndicationContent.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / NetFx35 / System.ServiceModel.Web / System / ServiceModel / Syndication / TextSyndicationContent.cs / 1 / TextSyndicationContent.cs

                            //------------------------------------------------------------ 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------

namespace System.ServiceModel.Syndication 
{
    using System; 
    using System.Collections.Generic; 
    using System.Text;
    using System.Xml; 
    using System.Xml.Schema;
    using System.Xml.Serialization;

    // NOTE: This class implements Clone so if you add any members, please update the copy ctor 
    public class TextSyndicationContent : SyndicationContent
    { 
        string text; 
        TextSyndicationContentKind textKind;
 
        public TextSyndicationContent(string text) : this(text, TextSyndicationContentKind.Plaintext)
        {
        }
 
        public TextSyndicationContent(string text, TextSyndicationContentKind textKind)
        { 
            if (!TextSyndicationContentKindHelper.IsDefined(textKind)) 
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("textKind")); 
            }
            this.text = text;
            this.textKind = textKind;
        } 

        protected TextSyndicationContent(TextSyndicationContent source) 
            : base(source) 
        {
            if (source == null) 
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("source");
            }
            this.text = source.text; 
            this.textKind = source.textKind;
        } 
 
        public string Text
        { 
            get { return this.text; }
        }

        public override string Type 
        {
            get 
            { 
                switch (this.textKind)
                { 
                    case TextSyndicationContentKind.Html:
                        return Atom10Constants.HtmlType;
                    case TextSyndicationContentKind.XHtml:
                        return Atom10Constants.XHtmlType; 
                    default:
                        return Atom10Constants.PlaintextType; 
                } 
            }
        } 

        public override SyndicationContent Clone()
        {
            return new TextSyndicationContent(this); 
        }
 
        protected override void WriteContentsTo(XmlWriter writer) 
        {
            string val = this.text ?? string.Empty; 
            if (this.textKind == TextSyndicationContentKind.XHtml)
            {
                writer.WriteRaw(val);
            } 
            else
            { 
                writer.WriteString(val); 
            }
        } 
    }
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK