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));
        }
Beispiel #2
0
        public static void Fill(UserConfiguration userConfiguration, ConfigurableObject configurableObject, IEnumerable <ProviderPropertyDefinition> appliedProperties)
        {
            IDictionary dictionary = userConfiguration.GetDictionary();

            foreach (ProviderPropertyDefinition providerPropertyDefinition in appliedProperties)
            {
                if (dictionary.Contains(providerPropertyDefinition.Name))
                {
                    configurableObject.propertyBag[providerPropertyDefinition] = StoreValueConverter.ConvertValueFromStore(providerPropertyDefinition, dictionary[providerPropertyDefinition.Name]);
                }
            }
        }
Beispiel #3
0
 private void LoadUserConfigurationToConfigObject(string userConfigurationName, XsoMailboxConfigurationObject configObject)
 {
     using (IReadableUserConfiguration readableUserConfiguration = this.getReadOnlyUserConfiguration(base.MailboxSession, userConfigurationName, UserConfigurationTypes.Dictionary, false))
     {
         if (readableUserConfiguration != null)
         {
             IDictionary dictionary = readableUserConfiguration.GetDictionary();
             foreach (PropertyDefinition propertyDefinition in configObject.Schema.AllProperties)
             {
                 XsoDictionaryPropertyDefinition xsoDictionaryPropertyDefinition = propertyDefinition as XsoDictionaryPropertyDefinition;
                 if (xsoDictionaryPropertyDefinition != null && !(xsoDictionaryPropertyDefinition.UserConfigurationName != userConfigurationName) && dictionary.Contains(xsoDictionaryPropertyDefinition.Name))
                 {
                     configObject.propertyBag.SetField(xsoDictionaryPropertyDefinition, StoreValueConverter.ConvertValueFromStore(xsoDictionaryPropertyDefinition, dictionary[xsoDictionaryPropertyDefinition.Name]));
                 }
             }
         }
     }
 }