private static void GetIntegerConstraints(ADSchemaAttributeObject schemaObject, ADPropertyDefinition propDef, List <PropertyDefinitionConstraint> constraints) { bool isUnlimited; bool isNullable; Type typeInformation = ADSchemaDataProvider.GetTypeInformation(propDef.Type, out isUnlimited, out isNullable); if (typeInformation == typeof(int)) { int minValue = schemaObject.RangeLower ?? int.MinValue; int maxValue = schemaObject.RangeUpper ?? int.MaxValue; constraints.Add(ADSchemaDataProvider.GetRangedConstraint <int>(minValue, maxValue, isUnlimited, isNullable)); return; } if (typeInformation == typeof(ByteQuantifiedSize)) { IFormatProvider formatProvider = propDef.FormatProvider; ByteQuantifiedSize.Quantifier quantifier = (formatProvider != null) ? ((ByteQuantifiedSize.Quantifier)formatProvider.GetFormat(typeof(ByteQuantifiedSize.Quantifier))) : ByteQuantifiedSize.Quantifier.None; ulong number = (ulong)((long)(schemaObject.RangeLower ?? 0)); int? rangeUpper = schemaObject.RangeUpper; ulong number2 = ((rangeUpper != null) ? new ulong?((ulong)((long)rangeUpper.GetValueOrDefault())) : null) ?? Math.Min((ulong)((ByteQuantifiedSize.Quantifier) 18446744073709551615UL / quantifier), 2147483647UL); ByteQuantifiedSize minValue2 = ByteQuantifiedSize.FromSpecifiedUnit(number, quantifier); ByteQuantifiedSize maxValue2 = ByteQuantifiedSize.FromSpecifiedUnit(number2, quantifier); constraints.Add(ADSchemaDataProvider.GetRangedConstraint <ByteQuantifiedSize>(minValue2, maxValue2, isUnlimited, isNullable)); return; } ExTraceGlobals.SchemaInitializationTracer.TraceDebug <DataSyntax, ADPropertyDefinition>(0L, "Unsupported property type '{1}' for data syntax '{0}'.", schemaObject.DataSyntax, propDef); }
private static bool IsKnownType(Type type) { bool flag; bool flag2; Type typeInformation = ADSchemaDataProvider.GetTypeInformation(type, out flag, out flag2); return(typeof(string) == typeInformation || typeof(int) == typeInformation || typeof(long) == typeInformation || typeof(ByteQuantifiedSize) == typeInformation || typeof(SmtpDomain) == typeInformation || typeof(SmtpAddress) == typeInformation || typeof(ProtocolConnectionSettings) == typeInformation || typeof(SmtpDomainWithSubdomains) == typeInformation || typeof(RoleEntry) == typeInformation || typeof(ProxyAddressTemplate) == typeInformation || typeof(UncFileSharePath) == typeInformation || typeof(NonRootLocalLongFullPath) == typeInformation || typeof(ProxyAddress) == typeInformation || typeof(byte[]) == typeInformation); }
private static void GetByteConstraints(ADSchemaAttributeObject schemaObject, ADPropertyDefinition propDef, List <PropertyDefinitionConstraint> constraints) { if (propDef.Type == typeof(byte[])) { constraints.Add(new ByteArrayLengthConstraint(schemaObject.RangeLower ?? 0, schemaObject.RangeUpper ?? 0)); return; } if (propDef.Type == typeof(string)) { ADSchemaDataProvider.GetStringConstraints(schemaObject, propDef, constraints); return; } ExTraceGlobals.SchemaInitializationTracer.TraceDebug <DataSyntax, ADPropertyDefinition>(0L, "Unsupported property type '{1}' for data syntax '{0}'.", schemaObject.DataSyntax, propDef); }
private PropertyDefinitionConstraint[] GeneratePropertyConstraints(ADSchemaAttributeObject schemaObject, ADPropertyDefinition propDef) { List <PropertyDefinitionConstraint> list = new List <PropertyDefinitionConstraint>(); switch (schemaObject.DataSyntax) { case DataSyntax.Boolean: case DataSyntax.Sid: case DataSyntax.ObjectIdentifier: case DataSyntax.UTCTime: case DataSyntax.GeneralizedTime: case DataSyntax.Interval: case DataSyntax.NTSecDesc: case DataSyntax.AccessPoint: case DataSyntax.DNBinary: case DataSyntax.DNString: case DataSyntax.DSDN: case DataSyntax.ORName: case DataSyntax.PresentationAddress: case DataSyntax.ReplicaLink: goto IL_BE; case DataSyntax.Integer: case DataSyntax.Enumeration: ADSchemaDataProvider.GetIntegerConstraints(schemaObject, propDef, list); goto IL_BE; case DataSyntax.Octet: ADSchemaDataProvider.GetByteConstraints(schemaObject, propDef, list); goto IL_BE; case DataSyntax.Numeric: case DataSyntax.Printable: case DataSyntax.Teletex: case DataSyntax.IA5: case DataSyntax.CaseSensitive: case DataSyntax.Unicode: ADSchemaDataProvider.GetStringConstraints(schemaObject, propDef, list); goto IL_BE; case DataSyntax.LargeInteger: ADSchemaDataProvider.GetLargeIntegerConstraints(schemaObject, propDef, list); goto IL_BE; } ExTraceGlobals.SchemaInitializationTracer.TraceDebug <DataSyntax, ADPropertyDefinition>((long)this.GetHashCode(), "Unsupported DataSyntax '{0}' found for property '{1}'.", schemaObject.DataSyntax, propDef); IL_BE: return(list.ToArray()); }
private void GetPropertiesToUpdate(IList <PropertyDefinition> properties, out List <ADPropertyDefinition> propertiesToRead, out List <ADPropertyDefinition> propertiesToUpdate) { propertiesToRead = new List <ADPropertyDefinition>(properties.Count); propertiesToUpdate = new List <ADPropertyDefinition>(properties.Count); for (int i = 0; i < properties.Count; i++) { ADPropertyDefinition adpropertyDefinition = properties[i] as ADPropertyDefinition; if (ADPropertyDefinition.CanHaveAutogeneratedConstraints(adpropertyDefinition) && ADSchemaDataProvider.IsKnownType(adpropertyDefinition.Type)) { propertiesToUpdate.Add(adpropertyDefinition); if (!this.constraintDictionary.ContainsKey(ADSchemaDataProvider.PropertyKey.GetPropertyKey(adpropertyDefinition))) { propertiesToRead.Add(adpropertyDefinition); } } } }