本文整理汇总了C#中ParserOptions.AddVariable方法的典型用法代码示例。如果您正苦于以下问题:C# ParserOptions.AddVariable方法的具体用法?C# ParserOptions.AddVariable怎么用?C# ParserOptions.AddVariable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParserOptions
的用法示例。
在下文中一共展示了ParserOptions.AddVariable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToParserOptions
public ParserOptions ToParserOptions()
{
var parserOptions = new ParserOptions();
foreach (var variable in Variables)
{
parserOptions.AddVariable(variable);
}
return parserOptions;
}
示例2: ParseSourceFilesSpecifications
public void ParseSourceFilesSpecifications()
{
Parser parser = null;
"Given new Parser".Context(() => parser = new Parser());
SourceFiles parserOutput = null;
"when ParseSourceFiles is invoked with SourceFiles"
.Do(() =>
{
var sourceFiles = new SourceFiles
{
new SourceFile("main.js", "@rivet includes.push(\"include.js\"); includes.push(\"dir/include.js\"); includes.push(\"dir/dir/include.js\");"),
new SourceFile("include.js", "BEFORE\r\nTEST//##DEBUG\r\nAFTER\r\n"),
new SourceFile("dir\\include.js", "BEFORE\r\n//##DEBUG_STARTTEST\r\n//##DEBUG_ENDAFTER\r\n"),
new SourceFile("dir\\dir\\include.js", "var i = @VARIABLE_1;var j = @VARIABLE_2;")
};
var parserOptions = new ParserOptions();
parserOptions.AddVariable(new Variable("VARIABLE_1", "1"));
parserOptions.AddVariable(new Variable("VARIABLE_2", "2"));
parserOutput = parser.ParseSourceFiles(sourceFiles, parserOptions);
});
"output contains 1 SourceFile".Assert(() => parserOutput.Count.ShouldEqual(1));
"Identity of output file is \"main.js\"".Assert(() => parserOutput.First().Identity.ShouldEqual("main.js"));
"Body of output file is \"BEFORE\r\nAFTER\r\nBEFORE\r\nAFTER\r\nvar i = 1;var j = 2;\"".Assert(() => parserOutput.First().Body.ShouldEqual("BEFORE\r\nAFTER\r\nBEFORE\r\nAFTER\r\nvar i = 1;var j = 2;"));
"first output file has 3 components".Assert(() => parserOutput.First().Components.Count.ShouldEqual(3));
"Identity of first component of output file is \"include.js\"".Assert(() => parserOutput.First().Components[0].Identity.ShouldEqual("include.js"));
"Identity of second component of output file is \"dir\\include.js\"".Assert(() => parserOutput.First().Components[1].Identity.ShouldEqual("dir\\include.js"));
"Identity of third component of output file is \"dir\\dir\\include.js\"".Assert(() => parserOutput.First().Components[2].Identity.ShouldEqual("dir\\dir\\include.js"));
}
示例3: ParseNestedSourceFilesSpecifications
public void ParseNestedSourceFilesSpecifications()
{
Parser parser = null;
"Given new Parser".Context(() => parser = new Parser());
SourceFiles parserOutput = null;
"when ParseSourceFiles is invoked with SourceFiles containing nested references"
.Do(() =>
{
var sourceFiles = new SourceFiles
{
new SourceFile("rivet-A.js", "@rivet includes.push(\"A.js\"); includes.push(\"rivet-B.js\");"),
new SourceFile("A.js", "A"),
new SourceFile("rivet-B.js", "@rivet includes.push(\"B.js\"); includes.push(\"rivet-C.js\");"),
new SourceFile("B.js", "B"),
new SourceFile("rivet-C.js", "@rivet includes.push(\"C1.js\"); includes.push(\"C2.js\");"),
new SourceFile("C1.js", "@VARIABLE"),
new SourceFile("C2.js", "C2"),
};
var parserOptions = new ParserOptions();
parserOptions.AddVariable(new Variable("VARIABLE", "C1"));
parserOutput = parser.ParseSourceFiles(sourceFiles, parserOptions);
});
"output contains 3 SourceFile".Assert(() => parserOutput.Count.ShouldEqual(3));
"group A nested references are resolved".Assert(() => parserOutput[0].Body.ShouldEqual("ABC1C2"));
"Rivet file A is made up of 4 components".Assert(() => parserOutput[0].Components.Count.ShouldEqual(4));
"group B nested references are resolved".Assert(() => parserOutput[1].Body.ShouldEqual("BC1C2"));
"Rivet file B is made up of 3 components".Assert(() => parserOutput[1].Components.Count.ShouldEqual(3));
"group C nested references are resolved".Assert(() => parserOutput[2].Body.ShouldEqual("C1C2"));
"Rivet file C is made up of 2 components".Assert(() => parserOutput[2].Components.Count.ShouldEqual(2));
}