public string Process(string input, Conventions conventions) { var styles = process.Parse(input); var styleBuilder = new StringBuilder(); foreach (var style in styles) { var setterBuilder = new StringBuilder(); foreach (var mapper in mappers) { if (!mapper.IsMatch(style)) continue; var result = mapper.Process(style); setterBuilder.AppendLine(); setterBuilder.AppendFormat(setterTemplate, result.Item1, result.Item2); } setterBuilder.AppendLine(); var type = conventions.GetTargetType(style.Name); var targetType = ""; if (!string.IsNullOrWhiteSpace(type)) { targetType = string.Format(" TargetType=\"{0}\"", type); } styleBuilder.AppendFormat(styleTemplate, style.Name, setterBuilder, targetType); styleBuilder.AppendLine(); } return styleBuilder.ToString(); }
public static string Generate(string input, Conventions conventions) { var mappers = new List<IMapper> { new BackgroundMapper(), new FontSizeMapper(), new FontFamilyMapper(), new MarginMapper() }; var processor = new CssProcessor(new CssParser(), mappers); return processor.Process(input, conventions); }