本文整理匯總了C#中Premake.Tests.Framework.Parser.Parse方法的典型用法代碼示例。如果您正苦於以下問題:C# Parser.Parse方法的具體用法?C# Parser.Parse怎麽用?C# Parser.Parse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Premake.Tests.Framework.Parser
的用法示例。
在下文中一共展示了Parser.Parse方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Run
public static void Run(Script script, Parser parser, Project expected, string[] options)
{
/* Remember where Premake is located */
string executable = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "premake";
/* Create a temporary directory for this run */
string temp = Path.GetTempPath() + Guid.NewGuid().ToString() + Path.DirectorySeparatorChar;
Directory.CreateDirectory(temp);
Directory.SetCurrentDirectory(temp);
/* Create any required files */
foreach (string filename in _files)
{
string dirname = Path.GetDirectoryName(filename);
if (dirname != String.Empty && !Directory.Exists(dirname))
Directory.CreateDirectory(dirname);
File.Create(filename).Close();
}
try
{
/* Write out the script */
script.WriteFile("premake.lua");
/* Run premake */
string args = (options != null) ? String.Join(" ", options) : String.Empty;
Process process = new Process();
process.StartInfo.FileName = executable;
process.StartInfo.Arguments = args + " --target " + parser.TargetName;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.WorkingDirectory = Directory.GetCurrentDirectory();
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.UseShellExecute = false;
process.Start();
process.WaitForExit();
Errors = process.StandardError.ReadToEnd();
Output = process.StandardOutput.ReadToEnd();
if (process.ExitCode != 0)
{
string message = (Errors != String.Empty) ? Errors : Output;
throw new InvalidOperationException("Premake aborted with code " + process.ExitCode + ": \n" + message);
}
/* Start building the results right here */
Project actual = new Project();
/* Locate the name of the just-written project file */
MatchCollection matches = Regex.Matches(script.ToString(), "project.name = '(.+)'");
actual.Name = matches[0].Groups[1].ToString();
matches = Regex.Matches(script.ToString(), "project.path = '(.+)'");
actual.Path = (matches.Count > 0) ? matches[0].Groups[1].ToString() : "";
/* Parse the results */
parser.Parse(actual, Path.Combine(actual.Path, actual.Name));
/* SHARPDEV_DEPENDENCY_BUG: Dependencies have disappeared! */
#if SHARPDEV_DEPENDENCY_BUG
foreach (Package p in actual.Package)
{
Console.WriteLine(p.Name + ":");
foreach (Configuration config in p.Config)
{
Console.WriteLine(" " + config.Name + ": " + config.Dependencies.Length);
}
}
#endif
expected.CompareTo(actual);
}
finally
{
Directory.SetCurrentDirectory(Path.GetDirectoryName(executable));
Directory.Delete(temp, true);
_files.Clear();
_scripts.Clear();
}
}