コード例 #1
0
 private static string ImplementationCodeSnippet(RegExMatchInfo info)
 {
     return(string.Format(@"[RegularExpression({0}, ErrorMessage = {1})]
 ",
                          CsUtility.QuotedString(info.RegularExpression),
                          CsUtility.QuotedString(info.ErrorMessage)));
 }
コード例 #2
0
        private static string ValidatorsCodeSnippet(RegExMatchInfo info)
        {
            string result = string.Format(
                @"{{Validator: RegexValidatorFactory(""{1}""), ErrorCode: 'notMatchingRegex', ErrorMessage: ""{2}"" }},
                ",
                info.Property.Name,
                info.RegularExpression.Replace("\\", "\\\\"),
                info.ErrorMessage);

            return(result);
        }
コード例 #3
0
        public void GenerateCode(IConceptInfo conceptInfo, ICodeBuilder codeBuilder)
        {
            if (conceptInfo is RegExMatchInfo)
            {
                RegExMatchInfo info = (RegExMatchInfo)conceptInfo;

                if (DataStructureCodeGenerator.IsTypeSupported(info.Property.DataStructure))
                {
                    codeBuilder.InsertCode(ImplementationCodeSnippet((RegExMatchInfo)info), MvcPropertyHelper.AttributeTag, info.Property);
                }
            }
        }
コード例 #4
0
 private static string AttrubuteParameters(RegExMatchInfo info)
 {
     return(string.Format(@"{0}, ErrorMessage = {1}",
                          CsUtility.QuotedString(info.RegularExpression),
                          CsUtility.QuotedString(info.ErrorMessage)));
 }