// Token: 0x06001001 RID: 4097 RVA: 0x0005B01C File Offset: 0x0005921C
        protected override void InternalCopyFrom(IProperty srcProperty)
        {
            IMIMEDataProperty imimedataProperty = srcProperty as IMIMEDataProperty;

            if (imimedataProperty == null)
            {
                throw new UnexpectedTypeException("IMIMEDataProperty", srcProperty);
            }
            if (!BodyUtility.IsAskingForMIMEData(imimedataProperty, base.Options))
            {
                return;
            }
            int  num  = -1;
            bool flag = false;

            imimedataProperty.MIMESize = imimedataProperty.MIMEData.Length;
            if (base.Options.Contains("MIMETruncation"))
            {
                num = (int)base.Options["MIMETruncation"];
            }
            if (num >= 0 && (long)num < imimedataProperty.MIMEData.Length)
            {
                flag = true;
                imimedataProperty.MIMESize = (long)num;
            }
            base.CreateAirSyncNode("MIMETruncated", flag ? "1" : "0");
            if (flag)
            {
                imimedataProperty.MIMESize = (long)num;
                base.CreateAirSyncNode("MIMESize", imimedataProperty.MIMEData.Length.ToString(CultureInfo.InvariantCulture));
            }
            base.CreateAirSyncNode("MIMEData", imimedataProperty.MIMEData, imimedataProperty.MIMESize, XmlNodeType.Text);
        }
Exemplo n.º 2
0
        // Token: 0x06000FB5 RID: 4021 RVA: 0x00059390 File Offset: 0x00057590
        protected override void InternalCopyFrom(IProperty sourceProperty)
        {
            IContentProperty contentProperty = sourceProperty as IContentProperty;

            if (contentProperty == null)
            {
                throw new UnexpectedTypeException("IContentProperty", sourceProperty);
            }
            contentProperty.PreProcessProperty();
            try
            {
                long num = 0L;
                bool flag;
                long num3;
                if (BodyUtility.IsAskingForMIMEData(contentProperty, base.Options) && this.IsAcceptable(BodyType.Mime, out num, out flag))
                {
                    int num2 = -1;
                    this.bodyType = BodyType.Mime;
                    this.MIMEData = contentProperty.MIMEData;
                    if (base.Options.Contains("MIMETruncation"))
                    {
                        num2 = (int)base.Options["MIMETruncation"];
                    }
                    if (num2 >= 0 && (long)num2 < this.MIMEData.Length)
                    {
                        this.Truncated = true;
                        this.MIMESize  = (long)num2;
                    }
                    else
                    {
                        this.Truncated = false;
                        this.MIMESize  = this.MIMEData.Length;
                    }
                    num3 = contentProperty.MIMEData.Length;
                }
                else
                {
                    this.bodyType = contentProperty.GetNativeType();
                    if (this.bodyType == BodyType.None)
                    {
                        return;
                    }
                    num3 = contentProperty.Size;
                    foreach (BodyType bodyType in AirSyncContentProperty.GetPrioritizedBodyTypes(this.bodyType))
                    {
                        try
                        {
                            long num4;
                            if (this.ClientAccepts(contentProperty, bodyType, out num4, out num))
                            {
                                this.bodyType = bodyType;
                                num3          = num4;
                                break;
                            }
                        }
                        catch (ObjectNotFoundException arg)
                        {
                            AirSyncDiagnostics.TraceInfo <BodyType, ObjectNotFoundException>(ExTraceGlobals.AirSyncTracer, this, "ClientAccepts({0}) has thrown {1}", bodyType, arg);
                            num3          = 0L;
                            this.bodyType = BodyType.None;
                        }
                    }
                }
                if (contentProperty.IsIrmErrorMessage)
                {
                    this.Truncated = true;
                }
                base.XmlNode = base.XmlParentNode.OwnerDocument.CreateElement(base.AirSyncTagNames[0], base.Namespace);
                base.XmlParentNode.AppendChild(base.XmlNode);
                XmlNode xmlNode     = base.XmlNode;
                string  elementName = "Type";
                int     num5        = (int)this.bodyType;
                base.AppendChildNode(xmlNode, elementName, num5.ToString(CultureInfo.InvariantCulture));
                base.AppendChildNode(base.XmlNode, "EstimatedDataSize", num3.ToString(CultureInfo.InvariantCulture));
                if (this.Truncated)
                {
                    base.AppendChildNode(base.XmlNode, "Truncated", "1");
                }
                this.CopyData();
            }
            finally
            {
                contentProperty.PostProcessProperty();
            }
        }
Exemplo n.º 3
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");
                    }
                }
            }
        }