Esempio n. 1
0
        internal static object MaximumPasswordAgeGetter(IPropertyBag propertyBag)
        {
            long?num = (long?)propertyBag[ADDomainSchema.MaximumPasswordAgeRaw];

            if (num == null)
            {
                return(null);
            }
            if (num.Value == -9223372036854775808L)
            {
                return(EnhancedTimeSpan.Zero);
            }
            return(new EnhancedTimeSpan?(EnhancedTimeSpan.FromTicks(-num.Value)));
        }
        // 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);
        }