Ejemplo n.º 1
0
        private void SetAttachmentItemProperty(Item item, object value)
        {
            FileAttachment propertyAttachment = EwsStoreObjectPropertyDefinition.GetPropertyAttachment(item, base.Name);

            if (value == null)
            {
                if (propertyAttachment != null)
                {
                    item.Attachments.Remove(propertyAttachment);
                    return;
                }
            }
            else
            {
                byte[] array = value as byte[];
                if (array == null)
                {
                    array = EwsStoreValueConverter.SerializeToBinary(value);
                }
                if (propertyAttachment != null)
                {
                    item.Attachments.Remove(propertyAttachment);
                }
                item.Attachments.AddFileAttachment(base.Name, array);
            }
        }
Ejemplo n.º 2
0
        private bool TryGetAttachmentItemProperty(Item item, out object result)
        {
            FileAttachment propertyAttachment = EwsStoreObjectPropertyDefinition.GetPropertyAttachment(item, base.Name);

            result = null;
            if (propertyAttachment != null)
            {
                int       num = 2;
                Exception ex;
                do
                {
                    ex = null;
                    try
                    {
                        propertyAttachment.Load();
                        goto IL_64;
                    }
                    catch (ServiceRemoteException ex2)
                    {
                        if (ex2 is ServiceResponseException && ((ServiceResponseException)ex2).ErrorCode == 131)
                        {
                            goto IL_64;
                        }
                        ex = ex2;
                    }
                    catch (ServiceLocalException ex3)
                    {
                        ex = ex3;
                    }
                }while (num-- > 0);
                throw new DataSourceOperationException(new LocalizedString(ex.Message), ex);
IL_64:
                if (base.Type != typeof(byte[]))
                {
                    if (propertyAttachment.Content != null && propertyAttachment.Content.Length > 0)
                    {
                        result = EwsStoreValueConverter.DeserializeFromBinary(propertyAttachment.Content);
                    }
                }
                else
                {
                    result = propertyAttachment.Content;
                }
                return(true);
            }
            return(false);
        }