本文整理汇总了C#中dotless.Core.Parser.Parser.Parse方法的典型用法代码示例。如果您正苦于以下问题:C# Parser.Parse方法的具体用法?C# Parser.Parse怎么用?C# Parser.Parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dotless.Core.Parser.Parser
的用法示例。
在下文中一共展示了Parser.Parse方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TransformToCss
public string TransformToCss(string source, string fileName)
{
var sb = new StringBuilder();
var parameters = parameterSource.GetParameters()
.Where(ValueIsNotNullOrEmpty);
var parser = new Parser.Parser();
sb.Append(source);
foreach (var parameter in parameters)
{
sb.AppendLine();
var variableDeclaration = string.Format("@{0}: {1};", parameter.Key, parameter.Value);
try
{
// Attempt to evaluate the generated variable to see if it's OK
parser.Parse(variableDeclaration, "").ToCSS(new Env());
sb.Append(variableDeclaration);
}
catch (ParserException)
{
// Result wasn't valid LESS, output a comment instead
sb.AppendFormat("/* Omitting variable '{0}'. The expression '{1}' is not valid. */", parameter.Key,
parameter.Value);
}
}
return Underlying.TransformToCss(sb.ToString(), fileName);
}
示例2: Execute
public override dotless.Core.Parser.Infrastructure.Nodes.Node Execute(dotless.Core.Parser.Infrastructure.Nodes.Node node, out bool visitDeeper)
{
visitDeeper = true;
if (node is Rule)
{
var rule = node as Rule;
if (rule.Variable)
{
if (_variables.ContainsKey(rule.Name.TrimStart(Convert.ToChar("@"))))
{
var overrideValue = _variables[rule.Name.TrimStart(Convert.ToChar("@"))];
if (!string.IsNullOrEmpty(overrideValue))
{
var parse = new Parser();
var ruleset = parse.Parse(rule.Name + ": " + overrideValue + ";", "variableoverrideplugin.less");
return ruleset.Rules[0] as Rule;
}
}
}
}
return node;
}
示例3: RuleExtractor
public RuleExtractor(string fileName)
{
var parser = new Parser(new PlainStylizer(), new Importer(new FileReader(new RelativeToFileLocationResolver(fileName))));
rules = parser.Parse(File.ReadAllText(fileName), fileName);
}