public static Schema WithValidationProperties(
            this Schema schema,
            JsonProperty jsonProperty)
        {
            PropertyInfo propertyInfo = jsonProperty.PropertyInfo();

            if (propertyInfo == (PropertyInfo)null)
            {
                return(schema);
            }
            foreach (object customAttribute in propertyInfo.GetCustomAttributes(false))
            {
                RegularExpressionAttribute expressionAttribute = customAttribute as RegularExpressionAttribute;
                if (expressionAttribute != null)
                {
                    schema.pattern = expressionAttribute.Pattern;
                }
                RangeAttribute rangeAttribute = customAttribute as RangeAttribute;
                if (rangeAttribute != null)
                {
                    int result1;
                    if (int.TryParse(rangeAttribute.Maximum.ToString(), out result1))
                    {
                        schema.maximum = new int?(result1);
                    }
                    int result2;
                    if (int.TryParse(rangeAttribute.Minimum.ToString(), out result2))
                    {
                        schema.minimum = new int?(result2);
                    }
                }
                StringLengthAttribute stringLengthAttribute = customAttribute as StringLengthAttribute;
                if (stringLengthAttribute != null)
                {
                    schema.maxLength = new int?(stringLengthAttribute.MaximumLength);
                    schema.minLength = new int?(stringLengthAttribute.MinimumLength);
                }
            }
            if (!jsonProperty.get_Writable())
            {
                schema.readOnly = new bool?(true);
            }
            return(schema);
        }