Ejemplo n.º 1
0
        // Token: 0x06000E78 RID: 3704 RVA: 0x00045564 File Offset: 0x00043764
        private static ADRawEntry ADRawEntryFromPropValues(ADObjectId id, bool createReadOnly, PropValue[] propValues, IEnumerable <MbxPropertyDefinition> properties, List <ValidationError> errors)
        {
            string        fqdn          = LocalServerCache.LocalServer.Fqdn;
            ADPropertyBag adpropertyBag = new ADPropertyBag(createReadOnly, 16);

            adpropertyBag.SetField(ADObjectSchema.Id, id);
            foreach (PropValue propValue in propValues)
            {
                if (!propValue.IsError())
                {
                    MbxPropertyDefinition   mbxPropertyDefinition   = ObjectSchema.GetInstance <MbxRecipientSchema>().FindPropertyDefinitionByPropTag(propValue.PropTag);
                    PropertyValidationError propertyValidationError = mbxPropertyDefinition.ValidateValue(propValue.Value, true);
                    if (propertyValidationError != null)
                    {
                        errors.Add(propertyValidationError);
                    }
                    adpropertyBag.SetField(mbxPropertyDefinition, SimpleStoreValueConverter.ConvertValueFromStore(mbxPropertyDefinition, propValue.Value));
                }
            }
            MbxRecipientSession.PopulateCustomizedCalculatedProperties(adpropertyBag, properties);
            ADRawEntry adrawEntry = new ADRawEntry(adpropertyBag);

            adrawEntry.OriginatingServer = fqdn;
            adrawEntry.WhenReadUTC       = new DateTime?(DateTime.UtcNow);
            adrawEntry.ResetChangeTracking(true);
            return(adrawEntry);
        }
        // Token: 0x06000E7F RID: 3711 RVA: 0x00045B38 File Offset: 0x00043D38
        internal static MultiValuedPropertyBase CreateGenericMultiValuedProperty(ProviderPropertyDefinition propertyDefinition, bool createAsReadOnly, ICollection values, ICollection invalidValues, LocalizedString?readOnlyErrorMessage)
        {
            MultiValuedPropertyBase result;

            if (!SimpleStoreValueConverter.TryCreateGenericMultiValuedProperty(propertyDefinition, createAsReadOnly, values, invalidValues, readOnlyErrorMessage, out result))
            {
                throw new NotImplementedException(DataStrings.ErrorMvpNotImplemented(propertyDefinition.Type.ToString(), propertyDefinition.Name));
            }
            return(result);
        }
Ejemplo n.º 3
0
        // Token: 0x06000E76 RID: 3702 RVA: 0x000453A8 File Offset: 0x000435A8
        private static PropValue[] PropValuesFromADPropertyBag(ADPropertyBag properties)
        {
            List <PropValue> list = new List <PropValue>();

            foreach (object obj in properties.Keys)
            {
                SimpleProviderPropertyDefinition simpleProviderPropertyDefinition = (SimpleProviderPropertyDefinition)obj;
                MbxPropertyDefinition            mbxPropertyDefinition            = simpleProviderPropertyDefinition as MbxPropertyDefinition;
                if (properties.IsChanged(simpleProviderPropertyDefinition) && mbxPropertyDefinition != null && mbxPropertyDefinition.PropTag != PropTag.Null)
                {
                    object value = SimpleStoreValueConverter.ConvertValueToStore(properties[mbxPropertyDefinition]);
                    list.Add(new PropValue(mbxPropertyDefinition.PropTag, value));
                }
            }
            return(list.ToArray());
        }
        // Token: 0x06000E7E RID: 3710 RVA: 0x00045A0C File Offset: 0x00043C0C
        internal static object ConvertValueToStore(object originalValue)
        {
            if (originalValue == null)
            {
                return(null);
            }
            if (originalValue is Enum)
            {
                return((int)originalValue);
            }
            if (originalValue is TimeSpan)
            {
                return((int)((TimeSpan)originalValue).TotalMinutes);
            }
            if (originalValue is Uri)
            {
                return(((Uri)originalValue).ToString());
            }
            if (originalValue is ADObjectId)
            {
                return(((ADObjectId)originalValue).GetBytes());
            }
            if (originalValue is MultiValuedProperty <string> )
            {
                return(SimpleStoreValueConverter.ConvertMvpStringToStringArray((MultiValuedProperty <string>)originalValue));
            }
            if (originalValue is MultiValuedProperty <int> )
            {
                return(SimpleStoreValueConverter.ConvertMvpIntToIntArray((MultiValuedProperty <int>)originalValue));
            }
            if (originalValue is MultiValuedProperty <ADObjectId> )
            {
                return(SimpleStoreValueConverter.ConvertMvpADObjectIdToStringArray((MultiValuedProperty <ADObjectId>)originalValue));
            }
            if (originalValue is MultiValuedProperty <KeywordHit> )
            {
                return(SimpleStoreValueConverter.ConvertMvpToStringArray <KeywordHit>((MultiValuedProperty <KeywordHit>)originalValue));
            }
            if (originalValue is MultiValuedProperty <DiscoverySearchStats> )
            {
                return(SimpleStoreValueConverter.ConvertMvpToStringArray <DiscoverySearchStats>((MultiValuedProperty <DiscoverySearchStats>)originalValue));
            }
            if (originalValue is CultureInfo)
            {
                return(originalValue.ToString());
            }
            if (originalValue is ExchangeObjectVersion)
            {
                return(((ExchangeObjectVersion)originalValue).ToInt64());
            }
            if (!(originalValue is Unlimited <EnhancedTimeSpan>))
            {
                return(originalValue);
            }
            Unlimited <EnhancedTimeSpan> value = (Unlimited <EnhancedTimeSpan>)originalValue;

            if (value == Unlimited <EnhancedTimeSpan> .UnlimitedValue)
            {
                return(null);
            }
            return(value.Value.Ticks);
        }
        // Token: 0x06000E7D RID: 3709 RVA: 0x00045858 File Offset: 0x00043A58
        internal static object ConvertValueFromStore(ProviderPropertyDefinition property, object originalValue)
        {
            if (originalValue == null)
            {
                return(null);
            }
            Type type = property.Type;

            if (type.Equals(originalValue.GetType()))
            {
                return(originalValue);
            }
            if (type.GetTypeInfo().IsEnum)
            {
                return(Enum.ToObject(type, originalValue));
            }
            if (type == typeof(TimeSpan))
            {
                return(TimeSpan.FromMinutes((double)((int)originalValue)));
            }
            if (type == typeof(Uri))
            {
                return(new Uri(originalValue.ToString(), UriKind.Absolute));
            }
            if (type == typeof(string) && property.IsMultivalued)
            {
                return(SimpleStoreValueConverter.ConvertStringArrayToMvpString(originalValue));
            }
            if (type == typeof(ADObjectId))
            {
                if (property.IsMultivalued)
                {
                    if (originalValue is byte[][])
                    {
                        return(SimpleStoreValueConverter.ConvertByteMatrixToMvpADObjectId(originalValue));
                    }
                    return(SimpleStoreValueConverter.ConvertStringArrayToMvpADObjectId(originalValue));
                }
                else if (originalValue is byte[])
                {
                    return(new ADObjectId((byte[])originalValue));
                }
            }
            if (type == typeof(KeywordHit) && property.IsMultivalued)
            {
                return(SimpleStoreValueConverter.ConvertStringArrayToMvpKeywordHit(originalValue));
            }
            if (type == typeof(int?) && property.IsMultivalued)
            {
                return(SimpleStoreValueConverter.ConvertIntArrayToMvpNullableInt(originalValue));
            }
            if (type == typeof(DiscoverySearchStats) && property.IsMultivalued)
            {
                return(SimpleStoreValueConverter.ConvertStringArrayToMvpDiscoverySearchStats(originalValue));
            }
            if (!(type == typeof(CultureInfo)))
            {
                if (type == typeof(Unlimited <EnhancedTimeSpan>))
                {
                    if (originalValue == null)
                    {
                        return(Unlimited <EnhancedTimeSpan> .UnlimitedValue);
                    }
                    if (originalValue is long)
                    {
                        return(new Unlimited <EnhancedTimeSpan>(EnhancedTimeSpan.FromTicks((long)originalValue)));
                    }
                }
                return(ValueConvertor.ConvertValue(originalValue, type, null));
            }
            if (originalValue != null)
            {
                return(new CultureInfo((string)originalValue));
            }
            return(null);
        }