本文整理汇总了C#中System.Text.RegularExpressions.Regex.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# Regex.AddRange方法的具体用法?C# Regex.AddRange怎么用?C# Regex.AddRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Text.RegularExpressions.Regex
的用法示例。
在下文中一共展示了Regex.AddRange方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompileClojureScript
private void CompileClojureScript(string filePath, string inputFileContents, Action<string> outputResult)
{
new System.Threading.Thread(() =>
{
outputResult("/* compiling ... */");
string runtimeDir = string.Format("{0}\\{1}-{2}", EnvironmentVariables.VsClojureRuntimesDir, Constants.CLOJURESCRIPT, Constants.VERSION);
List<string> paths = Directory.GetFiles(string.Format("{0}\\lib\\", runtimeDir), "*.jar", SearchOption.AllDirectories).ToList();
paths.Add(string.Format("{0}\\src\\clj", runtimeDir));
paths.Add(string.Format("{0}\\src\\cljs", runtimeDir));
paths.Add(string.Format("{0}\\lib", runtimeDir));
string classPath = paths.Aggregate((x, y) => x + ";" + y);
string compilerPath = String.Format("{0}\\bin\\cljsc.clj", runtimeDir);
string inputFileName = Path.GetTempFileName();
using (StreamWriter outfile = new StreamWriter(inputFileName))
{
outfile.Write(inputFileContents);
}
string workingDirectory = GetTempDirectory();
Process newProcess = new Process();
newProcess.StartInfo.UseShellExecute = false;
newProcess.StartInfo.RedirectStandardOutput = true;
newProcess.StartInfo.RedirectStandardError = true;
newProcess.StartInfo.CreateNoWindow = true;
newProcess.StartInfo.FileName = "java";
const string optimizations = OPTIMIZE_COMPILED_JAVASCRIPT ? "{:optimizations :advanced}" : "";
string arguments = string.Format("-server -cp \"{0}\" clojure.main \"{1}\" \"{2}\" {3}", classPath, compilerPath, inputFileName, optimizations);
newProcess.StartInfo.Arguments = arguments;
newProcess.StartInfo.WorkingDirectory = workingDirectory;
string standardOutput = "";
string standardError = "";
lock (filesBeingCompiledLock)
{
if (filesBeingCompiled.ContainsKey(filePath))
{
Process oldProcess = filesBeingCompiled[filePath];
try
{
oldProcess.Kill();
}
catch { }
}
filesBeingCompiled[filePath] = newProcess;
IntPtr oldWow64Redirection = new IntPtr();
Win32Api.Wow64DisableWow64FsRedirection(ref oldWow64Redirection);
try
{
newProcess.Start();
}
catch (Exception e)
{
standardError = e.Message + Environment.NewLine + "Ensure you have the latest version of Java and the JDK installed from Oracle.com" + Environment.NewLine + "Ensure the directory containing java is on the path environment variable (usually C:\\Program Files (x86)\\Java\\jre7\\bin)";
}
Win32Api.Wow64RevertWow64FsRedirection(oldWow64Redirection);
}
if (string.IsNullOrWhiteSpace(standardError))
{
standardOutput = newProcess.StandardOutput.ReadToEnd();
standardError = newProcess.StandardError.ReadToEnd();
newProcess.WaitForExit();
}
_errorListHelper.ClearErrors(filePath);
if (!string.IsNullOrWhiteSpace(standardError))
{
standardError = string.Format("/*{0}{1}{0}*/{0}", Environment.NewLine, standardError);
List<string> compilerErrors = new Regex("^Exception in thread \"main\" [^:]*:(.*)compiling:\\(.:[^:]*:([0-9]*):([0-9]*)\\)", RegexOptions.Multiline).Matches(standardError, 0).Cast<Match>().Select(x => string.Format("({0}, {1}, {0}, {1}): {2}", x.Groups[2].Value, x.Groups[3].Value, x.Groups[1].Value)).ToList();
compilerErrors.AddRange(new Regex("^Caused by:[^:]*:(.*)", RegexOptions.Multiline).Matches(standardError, 0).Cast<Match>().Select(x => x.Groups[1].Value).ToList());
foreach (string compilerError in compilerErrors)
{
_errorListHelper.Write(TaskCategory.BuildCompile, TaskErrorCategory.Error, compilerError, filePath);
}
}
if (!OPTIMIZE_COMPILED_JAVASCRIPT && !string.IsNullOrWhiteSpace(standardOutput))
{
string outDirectory = workingDirectory + "\\out";
if (Directory.Exists(outDirectory))
{
string outputFile = Directory.GetFiles(outDirectory, "*.js", SearchOption.TopDirectoryOnly).FirstOrDefault();
string outputFileContent = !string.IsNullOrWhiteSpace(outputFile) ? File.ReadAllText(outputFile) : "";
standardOutput = string.Format("/*{0}{1}{0}*/{0}{2}", Environment.NewLine, standardOutput, outputFileContent);
}
else
{
standardOutput = string.Format("/*{0}{1}{0}*/{0}", Environment.NewLine, standardOutput);
//.........这里部分代码省略.........