Ejemplo n.º 1
0
 protected virtual void Dispose(bool disposing)
 {
     if (!this.disposed)
     {
         if (disposing)
         {
             if (base.Actor != null)
             {
                 ExchangeItem exchangeItem = base.Actor as ExchangeItem;
                 if (exchangeItem != null && exchangeItem.Item != null)
                 {
                     exchangeItem.Item.Dispose();
                 }
                 base.Actor = null;
             }
             if (base.Action != null)
             {
                 ExchangeItem exchangeItem2 = base.Action.Item as ExchangeItem;
                 if (exchangeItem2 != null && exchangeItem2.Item != null)
                 {
                     exchangeItem2.Item.Dispose();
                 }
                 base.Action = null;
             }
             base.ItemToDelete = null;
         }
         this.disposed = true;
     }
 }
Ejemplo n.º 2
0
        public void SetContent(Item item, Guid attachContentId)
        {
            BinaryItem binaryItem = item as BinaryItem;

            if (binaryItem != null)
            {
                byte[] data;
                if (this.itemAttach.TryGetValue(attachContentId, out data))
                {
                    binaryItem.Data = data;
                    return;
                }
                throw new KeyNotFoundException(string.Format("Attachment with key {0} for item {1} not found", attachContentId, item.Identifier));
            }
            else
            {
                ExchangeItem exchangeItem = item as ExchangeItem;
                if (exchangeItem == null)
                {
                    throw new ArgumentException("Unexpected item type");
                }
                MessageItem item2;
                if (this.messageItemAttach.TryGetValue(attachContentId, out item2))
                {
                    exchangeItem.Item = item2;
                    return;
                }
                throw new KeyNotFoundException(string.Format("Attachment with key {0} for item {1} not found", attachContentId, item.Identifier));
            }
        }
Ejemplo n.º 3
0
        public static void Pack(Signal signal, MessageItem mailMessage)
        {
            List <Item> list = new List <Item>();

            using (MemoryStream memoryStream = new MemoryStream())
            {
                using (BinaryWriter binaryWriter = new BinaryWriter(memoryStream, Encoding.UTF8))
                {
                    binaryWriter.Write(1);
                    list = signal.WriteObject(binaryWriter);
                    using (TextWriter textWriter = mailMessage.Body.OpenTextWriter(BodyFormat.TextPlain))
                    {
                        textWriter.Write(Convert.ToBase64String(memoryStream.ToArray()));
                    }
                }
            }
            foreach (Item item in list)
            {
                ExchangeItem exchangeItem = item as ExchangeItem;
                if (exchangeItem != null)
                {
                    if (exchangeItem.Item.IsNew)
                    {
                        throw new ArgumentException("Item must be saved in order to attach.");
                    }
                    using (ItemAttachment itemAttachment = mailMessage.AttachmentCollection.AddExistingItem(exchangeItem.Item))
                    {
                        itemAttachment.ContentId = exchangeItem.AttachContentId.ToString();
                        itemAttachment.Save();
                    }
                }
            }
        }
Ejemplo n.º 4
0
 public override bool Equals(object obj)
 {
     if (!base.Equals(obj))
     {
         return(false);
     }
     if (obj != null)
     {
         ExchangeItem exchangeItem = obj as ExchangeItem;
         if (exchangeItem == null)
         {
             return(false);
         }
         if (this.Item != null)
         {
             return(this.Item.Equals(exchangeItem.Item));
         }
         if (exchangeItem.Item != null)
         {
             return(false);
         }
     }
     return(true);
 }