private static string ImplementationCodeSnippet(RegExMatchInfo info) { return(string.Format(@"[RegularExpression({0}, ErrorMessage = {1})] ", CsUtility.QuotedString(info.RegularExpression), CsUtility.QuotedString(info.ErrorMessage))); }
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); }
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); } } }
private static string AttrubuteParameters(RegExMatchInfo info) { return(string.Format(@"{0}, ErrorMessage = {1}", CsUtility.QuotedString(info.RegularExpression), CsUtility.QuotedString(info.ErrorMessage))); }