コード例 #1
0
 protected override string GenerateCode(RegExMatchInfo info)
 {
     return(ValidatorTemplates.Regex(
                Regex.Replace(info.RegularExpression, RegularExpressions.SingleQuoteEscape, RegularExpressions.SingleQuoteReplacement),
                StringHelper.EscapeSpecialCharacters(info.ErrorMessage, TypeScript.SpecialCharacters)
                ));
 }
コード例 #2
0
        public override string Generate(Table table, GeneratorOptions options)
        {
            var template = new ValidatorTemplates();

            template.Session = new Dictionary <string, object>();
            template.Session.Add("_namespace", AppSettings.Instance.Namespace);
            template.Session.Add("table", table);
            template.Session.Add("tableName", table.TableName);
            template.Session.Add("columns", table.InsertableColumns);
            template.Session.Add("options", options);

            template.Session.Add("tableNameToLower", $"{table.TableName.ElementAt(0).ToString().ToLower()}{table.TableName.Substring(1, table.TableName.Length - 1)}");

            template.Session.Add("tableNameToPascal", table.TableName.ToPascalCase());

            var fk = table.ForeignKeys.ToForegnTableColumns();

            template.Session.Add("foregnkeys", fk);



            template.Initialize();

            return(template.TransformText());
        }
コード例 #3
0
 protected override string GenerateCode(MaxLengthInfo info)
 {
     return(ValidatorTemplates.MaxLength(info.Property.Name, info.Length));
 }
コード例 #4
0
 protected override string GenerateCode(RequiredPropertyInfo info)
 {
     return(ValidatorTemplates.Required(info.Property.Name));
 }
コード例 #5
0
 protected override string GenerateCode(DecimalPropertyInfo info)
 {
     return(ValidatorTemplates.Decimal(RegularExpressions.Decimal.Replace("\\", "\\\\"), Messages.Errors.Decimal));
 }