Exemple #1
0
        // Token: 0x06000F44 RID: 3908 RVA: 0x00056F60 File Offset: 0x00055160
        protected override void InternalCopyFrom(IProperty srcProperty)
        {
            IAttachments12Property attachments12Property = srcProperty as IAttachments12Property;

            if (attachments12Property == null)
            {
                throw new UnexpectedTypeException("IAttachments12Property", srcProperty);
            }
            base.XmlNode = base.XmlParentNode.OwnerDocument.CreateElement(base.AirSyncTagNames[0], base.Namespace);
            foreach (Attachment12Data attachment12Data in attachments12Property)
            {
                XmlNode xmlNode = base.XmlParentNode.OwnerDocument.CreateElement("Attachment", base.Namespace);
                this.CopyAttachment(xmlNode, attachment12Data);
                if (attachment12Data.Id != null)
                {
                    this.nodeMap[attachment12Data.Id] = base.XmlNode.AppendChild(xmlNode);
                }
                else
                {
                    AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.XsoTracer, this, "Skip attachment {0}, its ID is null", attachment12Data.DisplayName);
                }
            }
            if (base.XmlNode.HasChildNodes)
            {
                base.XmlParentNode.AppendChild(base.XmlNode);
                base.PostProcessingDelegate = new PropertyBase.PostProcessProperties(this.PostProcessAttachments);
            }
        }
Exemple #2
0
        public override void CopyFrom(IProperty srcProperty)
        {
            IAttachments12Property attachments12Property = srcProperty as IAttachments12Property;

            if (attachments12Property == null)
            {
                throw new UnexpectedTypeException("IAttachments12Property", srcProperty);
            }
            List <IAttachment> list = new List <IAttachment>(attachments12Property.Count);

            foreach (Attachment12Data attachment12Data in attachments12Property)
            {
                Attachment16Data attachment16Data = attachment12Data as Attachment16Data;
                if (attachment16Data == null)
                {
                    throw new UnexpectedTypeException("Attachment16Data", attachment12Data);
                }
                IAttachment attachment = null;
                if (attachment16Data.ChangeType == AttachmentAction.Add)
                {
                    byte method = attachment16Data.Method;
                    if (method != 1)
                    {
                        if (method != 5)
                        {
                        }
                        throw new ConversionException(string.Format("The attachment method \"{0}\" is not suported.", attachment16Data.Method));
                    }
                    attachment = new FileAttachment
                    {
                        ContentId       = attachment16Data.ContentId,
                        ContentLocation = attachment16Data.ContentLocation,
                        Content         = attachment16Data.Content
                    };
                    attachment.Name        = attachment16Data.DisplayName;
                    attachment.IsInline    = attachment16Data.IsInline;
                    attachment.ContentType = attachment16Data.ContentType;
                    attachment.Id          = attachment16Data.ClientId;
                }
                else if (attachment16Data.ChangeType == AttachmentAction.Delete)
                {
                    if (!attachment16Data.FileReference.StartsWith(base.Item.Id + ":"))
                    {
                        throw new ConversionException(string.Format("The attachment \"{0}\" does not belog to the item \"{1}\".", attachment16Data.FileReference, base.Item.Id));
                    }
                    attachment    = new EntityDeleteAttachment();
                    attachment.Id = attachment16Data.FileReference.Substring(base.Item.Id.Length + 1);
                }
                list.Add(attachment);
            }
            base.Item.Attachments = list;
        }
        protected override void InternalCopyFromModified(IProperty srcProperty)
        {
            Item item = base.XsoItem as Item;

            if (item == null)
            {
                AirSyncDiagnostics.TraceError(ExTraceGlobals.RequestsTracer, null, "XSO16AttachmentProperty:InternalCopyFromModified. msgItem can not be null.");
                throw new UnexpectedTypeException("Item", base.XsoItem);
            }
            IAttachments12Property attachments12Property = srcProperty as IAttachments12Property;

            if (attachments12Property == null)
            {
                throw new UnexpectedTypeException("IAttachments12Property", srcProperty);
            }
            new List <IAttachment>(attachments12Property.Count);
            List <string> list = new List <string>();

            foreach (Attachment12Data attachment12Data in attachments12Property)
            {
                Attachment16Data attachment16Data = attachment12Data as Attachment16Data;
                if (attachment16Data == null)
                {
                    throw new UnexpectedTypeException("Attachment16Data", attachment12Data);
                }
                if (attachment16Data.ChangeType == AttachmentAction.Delete)
                {
                    list.Add(attachment16Data.FileReference);
                }
            }
            if (list.Count > 0)
            {
                AttachmentHelper.DeleteAttachments(item, list);
            }
            foreach (Attachment12Data attachment12Data2 in attachments12Property)
            {
                Attachment16Data attachment16Data2 = attachment12Data2 as Attachment16Data;
                if (attachment16Data2 == null)
                {
                    throw new UnexpectedTypeException("Attachment16Data", attachment12Data2);
                }
                if (attachment16Data2.ChangeType == AttachmentAction.Add)
                {
                    AttachmentHelper.CreateAttachment(item, attachment16Data2);
                }
            }
        }