Example #1
0
        protected override void InternalCopyFromModified(IProperty srcProperty)
        {
            Item          item         = (Item)base.XsoItem;
            IBodyProperty bodyProperty = (IBodyProperty)srcProperty;

            if (bodyProperty.RtfPresent)
            {
                if (bodyProperty.RtfData != null && bodyProperty.RtfData.Length > 0L)
                {
                    using (Stream stream = XsoBodyProperty.OpenBodyWriteStream(item, BodyFormat.ApplicationRtf))
                    {
                        StreamHelper.CopyStream(bodyProperty.RtfData, stream);
                        return;
                    }
                }
                using (TextWriter textWriter = item.Body.OpenTextWriter(BodyFormat.TextPlain))
                {
                    textWriter.Write(string.Empty);
                    return;
                }
            }
            if (bodyProperty.TextPresent)
            {
                using (Stream stream2 = XsoBodyProperty.OpenBodyWriteStream(item, BodyFormat.TextPlain))
                {
                    StreamHelper.CopyStream(bodyProperty.TextData, stream2);
                    return;
                }
            }
            throw new ConversionException("Source body property does not have Rtf or Text body present");
        }
Example #2
0
        protected override void InternalCopyFrom(IProperty srcProperty)
        {
            IBodyProperty bodyProperty = srcProperty as IBodyProperty;

            if (bodyProperty == null)
            {
                throw new UnexpectedTypeException("IBodyProperty", bodyProperty);
            }
            if (BodyUtility.IsAskingForMIMEData(bodyProperty, base.Options))
            {
                return;
            }
            bool flag  = false;
            bool flag2 = false;
            int  num   = 0;
            bool flag3 = false;

            this.cachedRtfNode = null;
            if (base.Options != null)
            {
                if (base.Options.Contains("ClientSupportsRtf"))
                {
                    flag = (bool)base.Options["ClientSupportsRtf"];
                }
                if (base.Options.Contains("MaxTextBodySize"))
                {
                    flag2 = true;
                    num   = (int)base.Options["MaxTextBodySize"];
                }
                if (base.Options.Contains("MaxRtfBodySize") && bodyProperty.RtfPresent)
                {
                    int num2 = (int)base.Options["MaxRtfBodySize"];
                    flag3 = (bodyProperty.RtfSize > (num2 / 3 + 1) * 4);
                }
            }
            if (flag && this.rtfBodyTag != null && bodyProperty.RtfPresent && !flag3)
            {
                AirSyncStream airSyncStream = bodyProperty.RtfData as AirSyncStream;
                if (airSyncStream == null || airSyncStream.Length == 0L)
                {
                    return;
                }
                airSyncStream.DoBase64Conversion = true;
                if (flag2)
                {
                    base.CreateAirSyncNode(this.bodyTruncatedTag, "0");
                }
                XmlNode xmlNode = base.AppendChildNode(base.XmlParentNode, this.rtfBodyTag, airSyncStream, -1L, XmlNodeType.Text);
                if (this.cacheRtf)
                {
                    this.cachedRtfNode = xmlNode;
                    return;
                }
            }
            else
            {
                if (!bodyProperty.TextPresent)
                {
                    return;
                }
                if (!flag2 || bodyProperty.TextSize <= num)
                {
                    Stream textData = bodyProperty.TextData;
                    if (bodyProperty.TextSize == 0)
                    {
                        return;
                    }
                    if (!this.writeBodyTruncatedLast && this.forceBodyTruncatedTag)
                    {
                        base.CreateAirSyncNode(this.bodyTruncatedTag, "0");
                    }
                    base.AppendChildNode(base.XmlParentNode, this.textBodyTag, textData, -1L, XmlNodeType.Text);
                    if (this.writeBodyTruncatedLast && this.forceBodyTruncatedTag)
                    {
                        base.CreateAirSyncNode(this.bodyTruncatedTag, "0");
                        return;
                    }
                }
                else
                {
                    Stream textData2 = bodyProperty.GetTextData(num);
                    if (bodyProperty.TextSize == 0)
                    {
                        return;
                    }
                    if (!this.writeBodyTruncatedLast)
                    {
                        base.CreateAirSyncNode(this.bodyTruncatedTag, "1");
                    }
                    if (this.bodySizeTag != null)
                    {
                        base.CreateAirSyncNode(this.bodySizeTag, bodyProperty.TextSize.ToString(CultureInfo.InvariantCulture));
                    }
                    base.AppendChildNode(base.XmlParentNode, this.textBodyTag, textData2, -1L, XmlNodeType.Text);
                    if (this.writeBodyTruncatedLast)
                    {
                        base.CreateAirSyncNode(this.bodyTruncatedTag, "1");
                    }
                }
            }
        }