Ejemplo n.º 1
0
        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);
        }