示例#1
0
        public static void CreatePostReplyForwardHeader(ReplyForwardConfiguration configuration, Item item, ForwardReplyHeaderOptions options, CultureInfo culture)
        {
            if (!(item is PostItem))
            {
                throw new ArgumentException("CreatePostReplyForwardheader is called on a non-PostItem item.");
            }
            PostItem      postItem      = (PostItem)item;
            StringBuilder stringBuilder = new StringBuilder();
            bool          outputHtml    = BodyFormat.TextHtml == configuration.TargetFormat;

            if (postItem.Sender != null)
            {
                if (postItem.From != null && string.Compare(postItem.Sender.DisplayName, postItem.From.DisplayName, StringComparison.Ordinal) != 0)
                {
                    stringBuilder.Append(string.Format(ClientStrings.OnBehalfOf.ToString(culture), ReplyForwardHeader.GetParticipantDisplayString(postItem.Sender, outputHtml), ReplyForwardHeader.GetParticipantDisplayString(postItem.From, outputHtml)));
                }
                else
                {
                    ReplyForwardHeader.AppendParticipantDisplayString(postItem.Sender, stringBuilder, outputHtml);
                }
            }
            string fromLabel = string.Empty;
            BodyInjectionFormat bodyPrefixFormat;
            string bodyPrefix;

            switch (configuration.TargetFormat)
            {
            case BodyFormat.TextPlain:
                fromLabel        = ClientStrings.FromColon.ToString(culture);
                bodyPrefixFormat = BodyInjectionFormat.Text;
                bodyPrefix       = ReplyForwardHeader.CreatePostTextReplyForwardHeader(postItem, options, fromLabel, stringBuilder.ToString(), culture, configuration.TimeZone);
                break;

            case BodyFormat.TextHtml:
                fromLabel        = ClientStrings.FromColon.ToString(culture);
                bodyPrefixFormat = BodyInjectionFormat.Html;
                bodyPrefix       = ReplyForwardHeader.CreatePostHtmlReplyForwardHeader(postItem, options, fromLabel, stringBuilder.ToString(), culture, configuration.TimeZone);
                break;

            default:
                throw new ArgumentException("Unsupported body format");
            }
            configuration.AddBodyPrefix(bodyPrefix, bodyPrefixFormat);
        }