private static Dictionary <string, ReplacementInfo> GetFieldMapping(string templateString) { Dictionary <string, ReplacementInfo> fieldMapping = new Dictionary <string, ReplacementInfo>(); Match match = Regex.Match(templateString, @"{(?<columns>\w+):(?<format>.+)}|{(?<columns>\w+)}", RegexOptions.Compiled); while (match.Success) { var key = match.Groups["columns"].Value; var replacementInfo = new ReplacementInfo { OriginalString = match.Value, FormatString = match.Groups["format"].Value }; if (!fieldMapping.ContainsKey(key)) { fieldMapping.Add(key, replacementInfo); } match = match.NextMatch(); } return(fieldMapping); }
public void AddPrimitveTemplate(string family, string primitiveTypeRegexp, string sliceNumberPattern, string template) { if (!m_mappings.ContainsKey(family)) { m_mappings.Add(family, new List <ReplacementInfo>()); } ReplacementInfo ri = new ReplacementInfo(); ri.PrimitveRegexp = primitiveTypeRegexp; ri.SliceNumberPattern = sliceNumberPattern; ri.Template = template; m_mappings[family].Add(ri); }