/// <summary>
        /// Creates a syndication feed item based on essential data.
        /// </summary>
        /// <param name="title">The title.</param>
        /// <param name="summary">The summary. Can be a string or a <see cref="RichText"/> instance.</param>
        /// <param name="link">The link.</param>
        /// <param name="publishDate">The date/time this item was published/created. If <c>null</c>, publish date is not included in the feed.</param>
        /// <param name="localization">The context <see cref="Localization"/>.</param>
        /// <returns>The syndication feed item.</returns>
        protected SyndicationItem CreateSyndicationItem(string title, object summary, Link link, DateTime?publishDate, Localization localization)
        {
            SyndicationItem result = new SyndicationItem
            {
                Title = new TextSyndicationContent(title),
            };

            if (summary != null)
            {
                TextSyndicationContentKind textKind = (summary is RichText) ? TextSyndicationContentKind.Html : TextSyndicationContentKind.Plaintext;
                result.Summary = new TextSyndicationContent(summary.ToString(), textKind);
            }

            SyndicationLink syndicationLink = CreateSyndicationLink(link, localization);

            if (syndicationLink != null)
            {
                result.Links.Add(syndicationLink);
            }

            if (publishDate.HasValue)
            {
                result.PublishDate = publishDate.Value;
            }

            return(result);
        }
示例#2
0
		protected TextSyndicationContent (TextSyndicationContent source)
		{
			if (source == null)
				throw new ArgumentNullException ("source");
			text = source.text;
			kind = source.kind;
		}
示例#3
0
 public static bool IsDefined(TextSyndicationContentKind kind)
 {
     if ((kind != TextSyndicationContentKind.Plaintext) && (kind != TextSyndicationContentKind.Html))
     {
         return(kind == TextSyndicationContentKind.XHtml);
     }
     return(true);
 }
示例#4
0
        public void Ctor_String_TextSyndicationContentKind(string text, TextSyndicationContentKind textKind, string type)
        {
            var content = new TextSyndicationContent(text, textKind);

            Assert.Empty(content.AttributeExtensions);
            Assert.Equal(text, content.Text);
            Assert.Equal(type, content.Type);
        }
 public static bool IsDefined(TextSyndicationContentKind kind)
 {
     if ((kind != TextSyndicationContentKind.Plaintext) && (kind != TextSyndicationContentKind.Html))
     {
         return (kind == TextSyndicationContentKind.XHtml);
     }
     return true;
 }
示例#6
0
 public TextSyndicationContent(string text, TextSyndicationContentKind textKind)
 {
     if (!TextSyndicationContentKindHelper.IsDefined(textKind))
     {
         throw new ArgumentOutOfRangeException(nameof(textKind));
     }
     _text     = text;
     _textKind = textKind;
 }
 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)
 {
     if (source == null)
     {
         throw new ArgumentNullException("source");
     }
     text = source.text;
     kind = source.kind;
 }
 protected TextSyndicationContent(TextSyndicationContent source) : base(source)
 {
     if (source == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("source");
     }
     this.text = source.text;
     this.textKind = source.textKind;
 }
 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;
 }
示例#12
0
 protected TextSyndicationContent(TextSyndicationContent source)
     : base(source)
 {
     if (source == null)
     {
         throw new ArgumentNullException(nameof(source));
     }
     _text     = source._text;
     _textKind = source._textKind;
 }
        public TextSyndicationContent(string text, TextSyndicationContentKind textKind)
        {
            if (textKind < TextSyndicationContentKind.Plaintext || textKind > TextSyndicationContentKind.XHtml)
            {
                throw new ArgumentOutOfRangeException(nameof(textKind));
            }

            Text      = text;
            _textKind = textKind;
        }
 protected TextSyndicationContent(TextSyndicationContent source)
     : base(source)
 {
     if (source == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(source));
     }
     _text     = source._text;
     _textKind = source._textKind;
 }
示例#15
0
        TextSyndicationContent ReadTextSyndicationContent(XmlReader reader)
        {
            TextSyndicationContentKind kind = TextSyndicationContentKind.Plaintext;

            switch (reader.GetAttribute("type"))
            {
            case "html":
                kind = TextSyndicationContentKind.Html;
                break;

            case "xhtml":
                kind = TextSyndicationContentKind.XHtml;
                break;
            }
            string text = reader.ReadElementContentAsString();
            TextSyndicationContent t = new TextSyndicationContent(text, kind);

            return(t);
        }
 public TextSyndicationContent(string text, TextSyndicationContentKind textKind)
 {
 }
示例#17
0
		public TextSyndicationContent (string text, TextSyndicationContentKind textKind)
		{
			this.text = text;
			kind = textKind;
		}
示例#18
0
		public TextSyndicationContent (string text)
			{
				this.text = text;
				this.type = TextSyndicationContentKind.Plaintext;
			}
示例#19
0
 public void Ctor_InvalidTextKind_ThrowsArgumentOutOfRangeException(TextSyndicationContentKind textKind)
 {
     AssertExtensions.Throws <ArgumentOutOfRangeException>("textKind", () => new TextSyndicationContent(null, textKind));
 }
示例#20
0
		public TextSyndicationContent (string text, TextSyndicationContentKind type)
			{
				this.text = text;
				this.type = type;
			}
 public TextSyndicationContent(string text, TextSyndicationContentKind textKind)
 {
 }
示例#22
0
 public static bool IsDefined(TextSyndicationContentKind kind)
 {
     return(kind == TextSyndicationContentKind.Plaintext ||
            kind == TextSyndicationContentKind.Html ||
            kind == TextSyndicationContentKind.XHtml);
 }
示例#23
0
 public TextSyndicationContent(string text, TextSyndicationContentKind textKind)
 {
     this.text = text;
     kind      = textKind;
 }
示例#24
0
 public TextSyndicationContent(string text, TextSyndicationContentKind type)
 {
     this.text = text;
     this.type = type;
 }
 protected TextSyndicationContent(TextSyndicationContent source) : base(source)
 {
     Debug.Assert(source != null, "The base constructor already checks if source is valid.");
     Text      = source.Text;
     _textKind = source._textKind;
 }
 public static bool IsDefined(TextSyndicationContentKind kind)
 {
     return (kind == TextSyndicationContentKind.Plaintext
         || kind == TextSyndicationContentKind.Html
         || kind == TextSyndicationContentKind.XHtml);
 }
示例#27
0
 public TextSyndicationContent(string text)
 {
     this.text = text;
     this.type = TextSyndicationContentKind.Plaintext;
 }
        /// <summary>
        /// Override of the base Visitor method, which actually performs mapping search and serialization
        /// </summary>
        /// <param name="targetSegment">Current segment being checked for mapping</param>
        /// <param name="kind">Which sub segments to serialize</param>
        /// <param name="provider">Data Service provider used for rights verification.</param>
        protected override void Serialize(EpmTargetPathSegment targetSegment, EpmSerializationKind kind, DataServiceProviderWrapper provider)
        {
            if (targetSegment.HasContent)
            {
                EntityPropertyMappingInfo epmInfo = targetSegment.EpmInfo;
                Object propertyValue;

                try
                {
                    propertyValue = epmInfo.ReadPropertyValue(this.Element, provider);
                }
                catch (System.Reflection.TargetInvocationException e)
                {
                    ErrorHandler.HandleTargetInvocationException(e);
                    throw;
                }

                if (propertyValue == null)
                {
                    this.nullValuedProperties.Add(epmInfo);
                }

                String textPropertyValue = propertyValue != null?PlainXmlSerializer.PrimitiveToString(propertyValue) : String.Empty;

                TextSyndicationContentKind contentKind = (TextSyndicationContentKind)epmInfo.Attribute.TargetTextContentKind;

                switch (epmInfo.Attribute.TargetSyndicationItem)
                {
                case SyndicationItemProperty.AuthorEmail:
                    this.CreateAuthor(false);
                    this.author.Email = textPropertyValue;
                    break;

                case SyndicationItemProperty.AuthorName:
                    this.CreateAuthor(false);
                    this.author.Name       = textPropertyValue;
                    this.authorNamePresent = true;
                    break;

                case SyndicationItemProperty.AuthorUri:
                    this.CreateAuthor(false);
                    this.author.Uri = textPropertyValue;
                    break;

                case SyndicationItemProperty.ContributorEmail:
                case SyndicationItemProperty.ContributorName:
                case SyndicationItemProperty.ContributorUri:
                    this.SetContributorProperty(epmInfo.Attribute.TargetSyndicationItem, textPropertyValue);
                    break;

                case SyndicationItemProperty.Updated:
                    this.Target.LastUpdatedTime = EpmSyndicationContentSerializer.GetDate(propertyValue, Strings.EpmSerializer_UpdatedHasWrongType);
                    break;

                case SyndicationItemProperty.Published:
                    this.Target.PublishDate = EpmSyndicationContentSerializer.GetDate(propertyValue, Strings.EpmSerializer_PublishedHasWrongType);
                    break;

                case SyndicationItemProperty.Rights:
                    this.Target.Copyright = new TextSyndicationContent(textPropertyValue, contentKind);
                    break;

                case SyndicationItemProperty.Summary:
                    this.Target.Summary = new TextSyndicationContent(textPropertyValue, contentKind);
                    break;

                case SyndicationItemProperty.Title:
                    this.Target.Title = new TextSyndicationContent(textPropertyValue, contentKind);
                    break;

                default:
                    Debug.Fail("Unhandled SyndicationItemProperty enum value - should never get here.");
                    break;
                }
            }
            else
            {
                base.Serialize(targetSegment, kind, provider);
            }
        }