public static void AppendRule(File input, StylesheetRule rule) { var contents = Encoding.UTF8.GetString(input.ContentBytes); contents += Environment.NewLine + Environment.NewLine + rule.ToString(); input.ContentBytes = Encoding.UTF8.GetBytes(contents); }
public static void ReplaceRule(File input, string oldRuleName, StylesheetRule rule) { var contents = Encoding.UTF8.GetString(input.ContentBytes); var ruleRegex = new Regex(string.Format(_ruleRegexFormat, oldRuleName), RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); contents = ruleRegex.Replace(contents, rule != null ? rule.ToString() : ""); input.ContentBytes = Encoding.UTF8.GetBytes(contents); }