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); } }
internal static object ConvertValueToStore(EwsStoreObjectPropertyDefinition property, object originalValue) { if (originalValue == null) { return(null); } Type type = originalValue.GetType(); if (type == typeof(ADRecipientOrAddress)) { ADRecipientOrAddress adrecipientOrAddress = (ADRecipientOrAddress)originalValue; return(new EmailAddress(adrecipientOrAddress.DisplayName, adrecipientOrAddress.Address, adrecipientOrAddress.RoutingType)); } if (type == typeof(MultiValuedProperty <ADRecipientOrAddress>)) { return((from x in (MultiValuedProperty <ADRecipientOrAddress>) originalValue select x.Address).ToArray <string>()); } if (type == typeof(AuditLogSearchId)) { return(((AuditLogSearchId)originalValue).Guid); } if (type == typeof(ADObjectId) && property.StorePropertyDefinition.Type == typeof(byte[])) { return(((ADObjectId)originalValue).GetBytes()); } if (type == typeof(MultiValuedProperty <ADObjectId>) && property.IsMultivalued && property.StorePropertyDefinition is ExtendedPropertyDefinition && ((ExtendedPropertyDefinition)property.StorePropertyDefinition).MapiType == 3) { return((from x in (MultiValuedProperty <ADObjectId>) originalValue select x.GetBytes()).ToArray <byte[]>()); } if (type != typeof(byte[]) && property.StorePropertyDefinition.Type == typeof(byte[])) { return(EwsStoreValueConverter.SerializeToBinary(originalValue)); } if (!(property.StorePropertyDefinition.Type == typeof(PolicyTag))) { return(ValueConvertor.ConvertValue(StoreValueConverter.ConvertValueToStore(originalValue), EwsStoreValueConverter.GetStorePropertyDefinitionActualType(property), null)); } if ((Guid?)originalValue == null) { return(null); } return(new PolicyTag(true, (Guid)originalValue)); }