我正在使用ExCSS来解析和操作样式表字符串。到目前为止,一切都很好。
但我找不到任何关于如何将操纵的样式规则转换为字符串的文档。
虽然代码可能与这个问题无关,但这就是我正在做的事情:
private string ManipulateCSS(string styles)
{
ExCSS.Parser parser = new ExCSS.Parser();
var stylesheet = parser.Parse(styles);
// here I perform specific manipulations
// which are not relevant to this question...
stylesheet.StyleRules
.SelectMany(r => r.Declarations)
.Where(d => d.Name == "<something>"
...
...
// Now, the next line is where I'm having issues:
// how to return the whole string with styles out of this ExCSS parser?
return stylesheet.StyleRules.ToString();
}
谢谢您的帮助!