internal static object ConvertValueFromStore(EwsStoreObjectPropertyDefinition property, object originalValue) { if (originalValue == null) { return(null); } Type type = originalValue.GetType(); if (type == typeof(EmailAddressCollection) && property.Type == typeof(ADRecipientOrAddress)) { return(new MultiValuedProperty <ADRecipientOrAddress>(false, property, (from x in (EmailAddressCollection)originalValue select EwsStoreValueConverter.ConvertValueFromStore(property, x)).ToArray <object>())); } if (type == typeof(PolicyTag)) { return(((PolicyTag)originalValue).RetentionId); } Type type2 = property.Type; if (type2 == typeof(ADRecipientOrAddress)) { EmailAddress emailAddress = (EmailAddress)originalValue; return(new ADRecipientOrAddress(new Participant(emailAddress.Name, emailAddress.Address, emailAddress.RoutingType))); } if (!(type2 != typeof(byte[])) || !(property.StorePropertyDefinition.Type == typeof(byte[])) || !(originalValue is byte[])) { return(StoreValueConverter.ConvertValueFromStore(property, originalValue)); } if (type2 == typeof(ADObjectId)) { return(StoreValueConverter.ConvertValueFromStore(property, originalValue)); } return(Convert.ChangeType(EwsStoreValueConverter.DeserializeFromBinary((byte[])originalValue), type2)); }
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); }