Ejemplo n.º 1
0
        internal static ADPropertyDefinition Int32BitfieldProperty(string name, int shift, ADPropertyDefinition fieldProperty)
        {
            CustomFilterBuilderDelegate customFilterBuilderDelegate = delegate(SinglePropertyFilter filter)
            {
                ComparisonFilter comparisonFilter = filter as ComparisonFilter;
                if (comparisonFilter == null || comparisonFilter.ComparisonOperator != ComparisonOperator.Equal)
                {
                    throw new ADFilterException(DirectoryStrings.ExceptionUnsupportedFilterForProperty(filter.Property.Name, filter.GetType(), typeof(ComparisonFilter)));
                }
                int         num         = 1;
                int         num2        = ((bool)comparisonFilter.PropertyValue) ? 1 : 0;
                int         num3        = (1 << num) - 1;
                uint        num4        = (uint)((uint)(num2 & num3) << shift);
                uint        num5        = (uint)((uint)(~(uint)num2 & num3) << shift);
                QueryFilter queryFilter = new NotFilter(new BitMaskOrFilter(fieldProperty, (ulong)num5));
                if (num2 != 0)
                {
                    return(new AndFilter(new QueryFilter[]
                    {
                        new BitMaskAndFilter(fieldProperty, (ulong)num4),
                        queryFilter
                    }));
                }
                return(queryFilter);
            };

            return(new ADPropertyDefinition(name, fieldProperty.VersionAdded, typeof(bool), null, ADPropertyDefinitionFlags.Calculated, false, PropertyDefinitionConstraint.None, PropertyDefinitionConstraint.None, new ADPropertyDefinition[]
            {
                fieldProperty
            }, customFilterBuilderDelegate, ADObject.FlagGetterDelegate(1 << shift, fieldProperty), ADObject.FlagSetterDelegate(1 << shift, fieldProperty), null, null));
        }
Ejemplo n.º 2
0
        internal static ADPropertyDefinition Int32BitfieldProperty(string name, int shift, int length, ADPropertyDefinition fieldProperty, PropertyDefinitionConstraint constraint)
        {
            object         defaultValue   = 0;
            GetterDelegate getterDelegate = delegate(IPropertyBag bag)
            {
                object obj = null;
                if (!(bag as ADPropertyBag).TryGetField(fieldProperty, ref obj))
                {
                    return(defaultValue);
                }
                if (obj == null)
                {
                    return(defaultValue);
                }
                int num  = (int)obj;
                int num2 = (1 << length) - 1;
                return(num2 & num >> shift);
            };
            SetterDelegate setterDelegate = delegate(object value, IPropertyBag bag)
            {
                int num  = (int)bag[fieldProperty];
                int num2 = (1 << length) - 1;
                int num3 = (int)value;
                num &= ~(num2 << shift);
                num |= (num3 & num2) << shift;
                bag[fieldProperty] = num;
            };
            CustomFilterBuilderDelegate customFilterBuilderDelegate = delegate(SinglePropertyFilter filter)
            {
                ComparisonFilter comparisonFilter = filter as ComparisonFilter;
                if (comparisonFilter == null || comparisonFilter.ComparisonOperator != ComparisonOperator.Equal)
                {
                    throw new ADFilterException(DirectoryStrings.ExceptionUnsupportedFilterForProperty(filter.Property.Name, filter.GetType(), typeof(ComparisonFilter)));
                }
                int         num         = (int)comparisonFilter.PropertyValue;
                int         num2        = (1 << length) - 1;
                uint        num3        = (uint)((uint)(num & num2) << shift);
                uint        num4        = (uint)((uint)(~(uint)num & num2) << shift);
                QueryFilter queryFilter = new NotFilter(new BitMaskOrFilter(fieldProperty, (ulong)num4));
                if (num != 0)
                {
                    return(new AndFilter(new QueryFilter[]
                    {
                        new BitMaskAndFilter(fieldProperty, (ulong)num3),
                        queryFilter
                    }));
                }
                return(queryFilter);
            };

            PropertyDefinitionConstraint[] readConstraints;
            if (constraint == null)
            {
                readConstraints = PropertyDefinitionConstraint.None;
            }
            else
            {
                readConstraints = new PropertyDefinitionConstraint[]
                {
                    constraint
                };
            }
            return(new ADPropertyDefinition(name, fieldProperty.VersionAdded, typeof(int), null, ADPropertyDefinitionFlags.Calculated, defaultValue, readConstraints, PropertyDefinitionConstraint.None, new ADPropertyDefinition[]
            {
                fieldProperty
            }, customFilterBuilderDelegate, getterDelegate, setterDelegate, null, null));
        }
Ejemplo n.º 3
0
 internal RegistryPropertyDefinition(string name, Type type, PropertyDefinitionFlags flags, object defaultValue, PropertyDefinitionConstraint[] readConstraints, PropertyDefinitionConstraint[] writeConstraints, ProviderPropertyDefinition[] supportingProperties, CustomFilterBuilderDelegate customFilterBuilderDelegate, GetterDelegate getterDelegate, SetterDelegate setterDelegate) : base(name, ExchangeObjectVersion.Exchange2003, type, (defaultValue != null) ? (flags | PropertyDefinitionFlags.PersistDefaultValue) : flags, defaultValue, readConstraints, writeConstraints, supportingProperties, customFilterBuilderDelegate, getterDelegate, setterDelegate)
 {
 }
        public ProviderPropertyDefinition(string name, ExchangeObjectVersion versionAdded, Type type, object defaultValue, PropertyDefinitionConstraint[] readConstraints, PropertyDefinitionConstraint[] writeConstraints, ProviderPropertyDefinition[] supportingProperties, CustomFilterBuilderDelegate customFilterBuilderDelegate, GetterDelegate getterDelegate, SetterDelegate setterDelegate) : base(name, type)
        {
            if (supportingProperties == null)
            {
                throw new ArgumentNullException("supportingProperties");
            }
            if (readConstraints == null)
            {
                throw new ArgumentNullException("readConstraints");
            }
            if (writeConstraints == null)
            {
                throw new ArgumentNullException("writeConstraints");
            }
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            if (versionAdded == null)
            {
                throw new ArgumentNullException("versionAdded");
            }
            if (defaultValue != null && !ReflectionHelper.IsInstanceOfType(defaultValue, type))
            {
                throw new ArgumentException(DataStrings.ExceptionDefaultTypeMismatch.ToString(), "defaultValue (" + name + ")");
            }
            if (type == typeof(bool) && defaultValue != null)
            {
                defaultValue = BoxedConstants.GetBool((bool)defaultValue);
            }
            this.defaultValue = defaultValue;
            this.customFilterBuilderDelegate = customFilterBuilderDelegate;
            this.versionAdded = versionAdded;
            if (readConstraints.Length < 1)
            {
                this.readOnlyReadConstraints = ProviderPropertyDefinition.EmptyConstraint.Collection;
            }
            else
            {
                this.readOnlyReadConstraints = new ReadOnlyCollection <PropertyDefinitionConstraint>(readConstraints);
            }
            if (writeConstraints.Length < 1 && readConstraints.Length < 1)
            {
                this.allStaticConstraints   = PropertyDefinitionConstraint.None;
                this.readOnlyAllConstraints = ProviderPropertyDefinition.EmptyConstraint.Collection;
            }
            else
            {
                this.allStaticConstraints = new PropertyDefinitionConstraint[readConstraints.Length + writeConstraints.Length];
                Array.Copy(writeConstraints, this.allStaticConstraints, writeConstraints.Length);
                Array.Copy(readConstraints, 0, this.allStaticConstraints, writeConstraints.Length, readConstraints.Length);
                this.readOnlyAllConstraints = new ReadOnlyCollection <PropertyDefinitionConstraint>(this.allStaticConstraints);
            }
            this.getterDelegate = getterDelegate;
            this.setterDelegate = setterDelegate;
            if (supportingProperties.Length < 1)
            {
                this.supportingProperties = ProviderPropertyDefinition.EmptyCollection;
            }
            else
            {
                this.supportingProperties = new ReadOnlyCollection <ProviderPropertyDefinition>(supportingProperties);
            }
            List <CollectionPropertyDefinitionConstraint> list  = new List <CollectionPropertyDefinitionConstraint>();
            List <CollectionPropertyDefinitionConstraint> list2 = new List <CollectionPropertyDefinitionConstraint>();

            for (int i = 0; i < writeConstraints.Length; i++)
            {
                CollectionPropertyDefinitionConstraint collectionPropertyDefinitionConstraint = writeConstraints[i] as CollectionPropertyDefinitionConstraint;
                if (collectionPropertyDefinitionConstraint != null)
                {
                    list.Add(collectionPropertyDefinitionConstraint);
                }
            }
            for (int j = 0; j < readConstraints.Length; j++)
            {
                CollectionPropertyDefinitionConstraint collectionPropertyDefinitionConstraint2 = readConstraints[j] as CollectionPropertyDefinitionConstraint;
                if (collectionPropertyDefinitionConstraint2 != null)
                {
                    list.Add(collectionPropertyDefinitionConstraint2);
                    list2.Add(collectionPropertyDefinitionConstraint2);
                }
            }
            if (list.Count < 1)
            {
                this.allStaticCollectionConstraints   = ProviderPropertyDefinition.EmptyCollectionConstraint.Array;
                this.readOnlyAllCollectionConstraints = ProviderPropertyDefinition.EmptyCollectionConstraint.Collection;
            }
            else
            {
                this.allStaticCollectionConstraints   = list.ToArray();
                this.readOnlyAllCollectionConstraints = new ReadOnlyCollection <CollectionPropertyDefinitionConstraint>(this.allStaticCollectionConstraints);
            }
            if (list2.Count < 1)
            {
                this.readOnlyReadCollectionConstraints = ProviderPropertyDefinition.EmptyCollectionConstraint.Collection;
            }
            else
            {
                this.readOnlyReadCollectionConstraints = new ReadOnlyCollection <CollectionPropertyDefinitionConstraint>(list2.ToArray());
            }
            this.readOnlyDependentProperties = ProviderPropertyDefinition.EmptyCollection;
            if (this.supportingProperties.Count == 0)
            {
                this.dependentProperties = new List <ProviderPropertyDefinition>();
            }
            foreach (ProviderPropertyDefinition providerPropertyDefinition in supportingProperties)
            {
                if (providerPropertyDefinition.IsCalculated)
                {
                    throw new ArgumentException(string.Format("The calculated property '{0}' cannot depend on another calculated property '{1}'", base.Name, providerPropertyDefinition.Name), "supportingProperties");
                }
                if (this.VersionAdded.IsOlderThan(providerPropertyDefinition.VersionAdded))
                {
                    throw new ArgumentException(string.Format("The calculated property '{0}' cannot depend on the newer property '{1}'", base.Name, providerPropertyDefinition.Name), "supportingProperties");
                }
                providerPropertyDefinition.AddDependency(this);
            }
            if (defaultValue != null && defaultValue != string.Empty)
            {
                PropertyValidationError propertyValidationError = this.ValidateValue(defaultValue, false);
                if (propertyValidationError != null)
                {
                    throw new ArgumentException(propertyValidationError.Description, "defaultValue");
                }
            }
        }
Ejemplo n.º 5
0
 internal ADPropertyDefinition(string name, ExchangeObjectVersion versionAdded, Type type, IFormatProvider formatProvider, string ldapDisplayName, string shadowLdapDisplayName, string softLinkLdapDisplayName, ADPropertyDefinitionFlags flags, object defaultValue, PropertyDefinitionConstraint[] readConstraints, PropertyDefinitionConstraint[] writeConstraints, ProviderPropertyDefinition[] supportingProperties, CustomFilterBuilderDelegate customFilterBuilderDelegate, GetterDelegate getterDelegate, SetterDelegate setterDelegate, SimpleProviderPropertyDefinition mservPropertyDefinition = null, SimpleProviderPropertyDefinition mbxPropertyDefinition = null) : base(name, versionAdded, type, (PropertyDefinitionFlags)flags, defaultValue, readConstraints, writeConstraints, supportingProperties, customFilterBuilderDelegate, getterDelegate, setterDelegate)
 {
     this.formatProvider          = formatProvider;
     this.ldapDisplayName         = ldapDisplayName;
     this.mservPropertyDefinition = mservPropertyDefinition;
     this.mbxPropertyDefinition   = mbxPropertyDefinition;
     if (string.IsNullOrEmpty(this.LdapDisplayName))
     {
         if (!this.IsCalculated && !this.IsTaskPopulated && !this.IsNonADProperty)
         {
             throw new ArgumentException(base.Name + ": Non-calculated properties must have LdapDisplayName", "ldapDisplayName");
         }
     }
     else
     {
         if (this.IsCalculated && base.CustomFilterBuilderDelegate != new CustomFilterBuilderDelegate(ADObject.DummyCustomFilterBuilderDelegate))
         {
             throw new ArgumentException(base.Name + ": Calculated properties should not contain an LdapDisplayName, unless it is the DummyCustomFilterBuilderDelegate.", "ldapDisplayName");
         }
         if (this.IsTaskPopulated)
         {
             throw new ArgumentException(base.Name + ": TaskPopulated properties should not contain an LdapDisplayName.", "ldapDisplayName");
         }
     }
     if (!this.IsMultivalued && !this.IsFilterOnly && !this.IsCalculated && !this.IsMandatory && base.Type == typeof(string) && !string.Empty.Equals(base.DefaultValue))
     {
         throw new ArgumentException(base.Name + ": Non-mandatory string properties must have default value String.Empty. Found " + (base.DefaultValue ?? "<null>"), "defaultValue");
     }
     if (this.IsValidateInFirstOrganization || this.IsDoNotValidate || this.IsBackLink)
     {
         if ((this.IsValidateInFirstOrganization && this.IsDoNotValidate) || (this.IsDoNotValidate && this.IsBackLink) || (this.IsValidateInFirstOrganization && this.IsBackLink))
         {
             throw new ArgumentException(base.Name + ": Only one of the three property definition flags - ValidateInFirstOrganization, DoNotValidate and BackLink can be set in parameter flags");
         }
         if (base.Type != typeof(ADObjectId))
         {
             throw new ArgumentException(base.Name + ": If ValidateInFirstOrganization, DoNotValidate or BackLink is set for parameter flags, the property type MUST be ADObjectId");
         }
     }
     if (this.IsRanged && (!this.IsMultivalued || string.IsNullOrEmpty(this.ldapDisplayName) || !this.IsReadOnly))
     {
         throw new ArgumentException(base.Name + ": Only multivalued non calculated properties can be ranged.");
     }
     if (!string.IsNullOrEmpty(this.ldapDisplayName) && this.IsRanged != this.ldapDisplayName.ToLower().Contains(";range="))
     {
         throw new ArgumentException(base.Name + ": Ranged property needs to define range in ldapName.");
     }
     if (!string.IsNullOrEmpty(shadowLdapDisplayName))
     {
         if (this.IsCalculated || this.IsReadOnly || this.IsFilterOnly || this.IsTaskPopulated || this.IsSoftLinkAttribute)
         {
             throw new ArgumentException(base.Name + ": Calculated, ReadOnly, FilterOnly, SoftLink, or TaskPopulated properties may not have shadows");
         }
         Type type2;
         ADPropertyDefinitionFlags flags2;
         object defaultValue2;
         if (type.GetTypeInfo().IsValueType&& (flags & ADPropertyDefinitionFlags.PersistDefaultValue) == ADPropertyDefinitionFlags.PersistDefaultValue)
         {
             Type typeFromHandle = typeof(Nullable <>);
             type2 = typeFromHandle.MakeGenericType(new Type[]
             {
                 type
             });
             flags2        = (flags & ~ADPropertyDefinitionFlags.PersistDefaultValue);
             defaultValue2 = null;
         }
         else
         {
             type2         = type;
             flags2        = flags;
             defaultValue2 = defaultValue;
         }
         this.shadowProperty = new ADPropertyDefinition(string.Format("Shadow{0}", name), ExchangeObjectVersion.Exchange2003, type2, formatProvider, shadowLdapDisplayName, null, null, flags2, defaultValue2, PropertyDefinitionConstraint.None, PropertyDefinitionConstraint.None, SimpleProviderPropertyDefinition.None, null, null, null, null, null);
     }
     if (!string.IsNullOrEmpty(softLinkLdapDisplayName))
     {
         if (this.IsCalculated || this.IsReadOnly || this.IsFilterOnly || this.IsTaskPopulated)
         {
             throw new ArgumentException(base.Name + ": Calculated, ReadOnly, FilterOnly, or TaskPopulated properties may not have soft links");
         }
         Type typeFromHandle2             = typeof(byte[]);
         ADPropertyDefinitionFlags flags3 = ADPropertyDefinitionFlags.Binary;
         this.softLinkShadowProperty = new ADPropertyDefinition(string.Format("{0}_sl", name), ExchangeObjectVersion.Exchange2003, typeFromHandle2, formatProvider, softLinkLdapDisplayName, null, null, flags3, null, PropertyDefinitionConstraint.None, PropertyDefinitionConstraint.None, SimpleProviderPropertyDefinition.None, null, null, null, null, null);
     }
 }
Ejemplo n.º 6
0
 internal ADPropertyDefinition(string name, ExchangeObjectVersion versionAdded, Type type, string ldapDisplayName, ADPropertyDefinitionFlags flags, object defaultValue, PropertyDefinitionConstraint[] readConstraints, PropertyDefinitionConstraint[] writeConstraints, ProviderPropertyDefinition[] supportingProperties, CustomFilterBuilderDelegate customFilterBuilderDelegate, GetterDelegate getterDelegate, SetterDelegate setterDelegate, SimpleProviderPropertyDefinition mservPropertyDefinition = null, SimpleProviderPropertyDefinition mbxPropertyDefinition = null) : this(name, versionAdded, type, null, ldapDisplayName, null, flags, defaultValue, readConstraints, writeConstraints, supportingProperties, customFilterBuilderDelegate, getterDelegate, setterDelegate, mservPropertyDefinition, mbxPropertyDefinition)
 {
 }
Ejemplo n.º 7
0
 private MapiPropertyDefinition(string name, Type type, PropTag propertyTag, MapiPropertyDefinitionFlags propertyDefinitionFlags, object defaultValue, object initialValue, MapiPropValueExtractorDelegate propertyValueExtractor, MapiPropValuePackerDelegate propertyValuePacker, PropertyDefinitionConstraint[] readConstraints, PropertyDefinitionConstraint[] writeConstraints, ProviderPropertyDefinition[] supportingProperties, CustomFilterBuilderDelegate customFilterBuilderDelegate, GetterDelegate getterDelegate, SetterDelegate setterDelegate) : base(name ?? propertyTag.ToString(), ExchangeObjectVersion.Exchange2003, type ?? MapiPropValueConvertor.TypeFromPropType(propertyTag.ValueType(), true), defaultValue, readConstraints ?? PropertyDefinitionConstraint.None, writeConstraints ?? PropertyDefinitionConstraint.None, supportingProperties ?? ProviderPropertyDefinition.None, customFilterBuilderDelegate, getterDelegate, setterDelegate)
 {
     this.propertyTag = propertyTag;
     if (((PropTag)12288U & propertyTag) != PropTag.Null)
     {
         propertyDefinitionFlags |= MapiPropertyDefinitionFlags.MultiValued;
     }
     this.propertyDefinitionFlags = propertyDefinitionFlags;
     this.initialValue            = initialValue;
     this.propertyValueExtractor  = (propertyValueExtractor ?? new MapiPropValueExtractorDelegate(MapiPropValueConvertor.Extract));
     this.propertyValuePacker     = (propertyValuePacker ?? new MapiPropValuePackerDelegate(MapiPropValueConvertor.Pack));
 }
Ejemplo n.º 8
0
 public MapiPropertyDefinition(string name, Type type, object defaultValue, MapiPropertyDefinitionFlags propertyDefinitionFlags, PropertyDefinitionConstraint[] readConstraints, PropertyDefinitionConstraint[] writeConstraints, ProviderPropertyDefinition[] supportingProperties, CustomFilterBuilderDelegate customFilterBuilderDelegate, GetterDelegate getterDelegate, SetterDelegate setterDelegate) : this(name, type, PropTag.Null, propertyDefinitionFlags, defaultValue, null, null, null, readConstraints, writeConstraints, supportingProperties, customFilterBuilderDelegate, getterDelegate, setterDelegate)
 {
 }
        internal SimpleProviderPropertyDefinition(string name, ExchangeObjectVersion versionAdded, Type type, PropertyDefinitionFlags flags, object defaultValue, PropertyDefinitionConstraint[] readConstraints, PropertyDefinitionConstraint[] writeConstraints, ProviderPropertyDefinition[] supportingProperties, CustomFilterBuilderDelegate customFilterBuilderDelegate, GetterDelegate getterDelegate, SetterDelegate setterDelegate) : base(name, versionAdded, type, defaultValue, readConstraints, writeConstraints, supportingProperties, customFilterBuilderDelegate, getterDelegate, setterDelegate)
        {
            this.flags = (int)flags;
            Type left = base.Type.GetTypeInfo().IsGenericType ? base.Type.GetTypeInfo().GetGenericTypeDefinition() : null;

            if (typeof(ICollection).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo()) && typeof(byte[]) != type && !this.IsKnownFailure(type))
            {
                if (this.IsMultivalued)
                {
                    throw new ArgumentException(base.Name + ": Only specify the element type for MultiValued properties. Type: " + type.FullName, "type");
                }
                throw new ArgumentException(base.Name + ": Instead of specifying a collection type, please mark the property definition as MultiValued and specify the element type as the type Type: " + type.FullName, "type");
            }
            else
            {
                if (this.IsMultivalued && base.DefaultValue != null)
                {
                    throw new ArgumentException(base.Name + ": Multivalued properties should not have default value", "defaultValue");
                }
                if (base.DefaultValue == null && this.PersistDefaultValue)
                {
                    throw new ArgumentException(base.Name + ": Cannot persist default value when no default value is specified.", "defaultValue");
                }
                if (this.IsTaskPopulated)
                {
                    if (this.IsFilterOnly)
                    {
                        throw new ArgumentException(base.Name + ": TaskPopulated properties are not supported as FilterOnly properties at this time.", "flags");
                    }
                    if (this.IsCalculated)
                    {
                        throw new ArgumentException(base.Name + ": TaskPopulated properties should not be marked as calculated.", "flags");
                    }
                    if (this.IsReadOnly || this.IsWriteOnce)
                    {
                        throw new ArgumentException(base.Name + ": TaskPopulated properties must be modifiable from within the task and cannot be marked ReadOnly or WriteOnce.", "flags");
                    }
                }
                if (this.IsWriteOnce && this.IsReadOnly)
                {
                    throw new ArgumentException(base.Name + ": Properties cannot be marked as both ReadOnly and WriteOnce.", "flags");
                }
                if (this.IsMandatory && this.IsFilterOnly)
                {
                    throw new ArgumentException(base.Name + ": Mandatory properties should not be marked FilterOnly.", "flags");
                }
                if (this.IsFilterOnly && this.IsCalculated)
                {
                    throw new ArgumentException(base.Name + ": Calculated properties should not be marked as FilterOnly.", "flags");
                }
                if (!this.IsMultivalued && !this.IsFilterOnly && !this.IsCalculated)
                {
                    Type underlyingType = Nullable.GetUnderlyingType(type);
                    if (base.Type.GetTypeInfo().IsValueType&& left != typeof(Nullable <>) && base.DefaultValue == null)
                    {
                        throw new ArgumentException(base.Name + ": Value type properties must have default value.", "defaultValue");
                    }
                    if (left == typeof(Nullable <>) && base.DefaultValue != null)
                    {
                        throw new ArgumentException(base.Name + ": Default value for a property of Nullable type must be 'null'.", "defaultValue");
                    }
                    if (null != underlyingType && underlyingType.GetTypeInfo().IsGenericType&& underlyingType.GetGenericTypeDefinition() == typeof(Unlimited <>))
                    {
                        throw new ArgumentException(base.Name + ": Properties cannot be both Unlimited and Nullable.", "type");
                    }
                    if (left == typeof(Unlimited <>) && !(bool)base.Type.GetTypeInfo().GetDeclaredProperty("IsUnlimited").GetValue(base.DefaultValue, null))
                    {
                        throw new ArgumentException(base.Name + ": Default value for a property of Unlimited type must be 'unlimited'.", "defaultValue");
                    }
                    if (left == typeof(Unlimited <>) && this.PersistDefaultValue)
                    {
                        throw new ArgumentException(base.Name + ": Cannot persist default value for Unlimited type.", "flags");
                    }
                }
                if (this.IsCalculated != (base.GetterDelegate != null))
                {
                    throw new ArgumentException(base.Name + ": Calculated properties must have GetterDelegate, non-calculated ones must not", "getterDelegate");
                }
                if ((this.IsCalculated && !this.IsReadOnly) != (base.SetterDelegate != null))
                {
                    throw new ArgumentException(base.Name + ": Writable calculated properties must have SetterDelegate, non-calculated & readonly ones must not", "setterDelegate");
                }
                if (this.IsCalculated != (base.SupportingProperties.Count != 0))
                {
                    throw new ArgumentException(base.Name + ": Calculated properties must have supporting properties, non-calculated ones must not", "supportingProperties");
                }
                if (this.IsReadOnly && writeConstraints.Length > 0)
                {
                    throw new ArgumentException(base.Name + ": Readonly properties should not have write-only constraints", "writeConstraints");
                }
                if (base.DefaultValue != null && !this.PersistDefaultValue && !this.IsCalculated && !this.IsTaskPopulated && (base.Type == typeof(int) || base.Type == typeof(uint) || base.Type == typeof(long) || base.Type == typeof(ulong) || base.Type == typeof(ByteQuantifiedSize) || base.Type == typeof(EnhancedTimeSpan) || base.Type == typeof(DateTime)))
                {
                    throw new ArgumentException(string.Format("Property {0} has type {1} and a default value that is not persisted", base.Name, base.Type.ToString()), "flags");
                }
                if (this.IsCalculated && base.Type.GetTypeInfo().IsValueType&& left != typeof(Nullable <>) && base.DefaultValue == null && !this.IsMultivalued)
                {
                    throw new ArgumentException(string.Format("Calculated property {0} has type {1} and no default value", base.Name, base.Type.ToString()), "flags");
                }
                return;
            }
        }
        private SyncPropertyDefinition(string name, string msoPropertyName, ExchangeObjectVersion versionAdded, Type type, Type externalType, string ldapDisplayName, ADPropertyDefinitionFlags flags, SyncPropertyDefinitionFlags syncFlags, ServerVersion syncVersionAdded, object defaultValue, ProviderPropertyDefinition[] supportingProperties, CustomFilterBuilderDelegate customFilterBuilderDelegate, GetterDelegate getterDelegate, SetterDelegate setterDelegate, ADPropertyDefinition shadowProperty) : base(name, versionAdded, type, ldapDisplayName, SyncPropertyDefinition.CalculateFlags(ldapDisplayName, (ADPropertyDefinitionFlags)(syncFlags | (SyncPropertyDefinitionFlags)flags)), defaultValue, PropertyDefinitionConstraint.None, PropertyDefinitionConstraint.None, supportingProperties, customFilterBuilderDelegate, getterDelegate, setterDelegate, null, null)
        {
            this.externalType             = externalType;
            this.MsoPropertyName          = msoPropertyName;
            this.SyncPropertyVersionAdded = syncVersionAdded;
            SyncPropertyDefinitionFlags syncPropertyDefinitionFlags = syncFlags & ~(SyncPropertyDefinitionFlags.ForwardSync | SyncPropertyDefinitionFlags.BackSync);

            syncPropertyDefinitionFlags |= SyncPropertyDefinitionFlags.Shadow;
            if (shadowProperty != null)
            {
                Type type2 = shadowProperty.Type;
                if (type2 == typeof(ADObjectId))
                {
                    type2 = typeof(SyncLink);
                }
                this.shadowProperty = new SyncPropertyDefinition(shadowProperty, msoPropertyName, type2, externalType, syncPropertyDefinitionFlags, syncVersionAdded);
                return;
            }
            if (this.IsBackSync && base.SupportingProperties.Count == 1 && ((ADPropertyDefinition)base.SupportingProperties[0]).ShadowProperty != null)
            {
                this.shadowProperty = new SyncPropertyDefinition(string.Format(CultureInfo.InvariantCulture, "Shadow{0}", new object[]
                {
                    base.Name
                }), msoPropertyName, base.Type, this.ExternalType, syncPropertyDefinitionFlags, syncVersionAdded, base.DefaultValue, new ProviderPropertyDefinition[]
                {
                    ((ADPropertyDefinition)base.SupportingProperties[0]).ShadowProperty
                }, base.GetterDelegate, base.SetterDelegate);
            }
        }
Ejemplo n.º 11
0
 public SimplePropertyDefinition(string name, ExchangeObjectVersion versionAdded, Type type, PropertyDefinitionFlags flags, object defaultValue, object initialValue, PropertyDefinitionConstraint[] readConstraints, PropertyDefinitionConstraint[] writeConstraints, ProviderPropertyDefinition[] supportingProperties, CustomFilterBuilderDelegate customFilterBuilderDelegate, GetterDelegate getterDelegate, SetterDelegate setterDelegate) : base(name, versionAdded, type, defaultValue, readConstraints, writeConstraints, supportingProperties, customFilterBuilderDelegate, getterDelegate, setterDelegate)
 {
     this.PropertyDefinitionFlags = flags;
     this.InitialValue            = initialValue;
 }