/// <summary> /// Task teardown work that should not be measured for that specific task. By /// default it does nothing, but tasks can implement this, moving work from /// <see cref="DoLogic()"/> to this method. Only the work done in <see cref="DoLogic()"/> /// is measured for this task. Notice that higher level (sequence) tasks /// containing this task would then measure larger time than the sum of their /// contained tasks. /// </summary> public virtual void TearDown() { if (++logStepCount % m_logStep == 0) { double time = (((Stopwatch.GetTimestamp() / Stopwatch.Frequency) * 1000) - runData.StartTimeMillis) / 1000.0; SystemConsole.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0:0000000.00}", time) + " sec --> " + Thread.CurrentThread.Name + " " + GetLogMessage(logStepCount)); } }
private List <Project> LoadProjects(Arguments args) { List <Project> projects = new List <Project>(); var solutionFileNames = args.Parameters.ToArray(); if (solutionFileNames.Length == 0) { solutionFileNames = Directory.GetFiles(".", "*.sln"); } foreach (string solutionFileName in solutionFileNames) { string file = Path.GetFullPath(FileSystem.Combine(".", solutionFileName)); SystemConsole.WriteLine("Loading {0}", file); if (File.Exists(file)) { string folder = Path.GetDirectoryName(file); int projectNumber = 0; foreach (string s in File.ReadAllLines(file).Where(s => s.StartsWith("Project("))) { projectNumber++; string fileName = null; try { string name = s.Substring(s.IndexOf('=')); name = name.Split(new string[] { "\", \"" }, StringSplitOptions.None)[1]; fileName = Path.Combine(folder, name); SystemConsole.WriteLine("Loading project {0} {1}", projectNumber, fileName); if (File.Exists(fileName)) { Project project = new Project(fileName, null, null, new ProjectCollection()); projects.Add(project); Solution = file; } } catch (Exception ex) { if (IsConsoleMode) { if (fileName != null) { SystemConsole.WriteLine("Could not load project {0}", fileName); SystemConsole.WriteLine(ex.ToXT()); } else { SystemConsole.WriteLine("Could not load project {0}", projectNumber); SystemConsole.WriteLine(ex.ToXT()); } } throw; MessageBox.Show(ex.ToString()); } } } } return(projects); }
public CopyToOneFolder() { SystemConsole.Run(config: new Dictionary <string, Action>() { { "递归搜索文件重命名并复制到同一文件夹下:搜索", CopyToOne }, { "递归搜索文件重命名并复制到同一文件夹下:还原", RevertCopyToOne }, { "原结构复制", CopyTo }, }); }
private void InitConsole() { System.Console.CursorVisible = false; ConsoleOut = System.Console.Out; Console = new SystemConsole(); Renderer = new ConsoleRenderSystem(Console, Console.WindowWidth, Console.WindowHeight); Console.Clear(); }
public override int DoLogic() { Report rp = ReportAll(RunData.Points.TaskStats); SystemConsole.WriteLine(); SystemConsole.WriteLine("------------> Report All (" + rp.Count + " out of " + rp.OutOf + ")"); SystemConsole.WriteLine(rp.Text); SystemConsole.WriteLine(); return(0); }
private static void Main(string[] args) { Action <object> callAction = delegate(object o) { BaseActionBy baseActionFor = (BaseActionBy)o; baseActionFor.Open(); }; SystemConsole.Run <ConvertType>(callAction); }
private void XAutoPropertyTest() { var console = new SystemConsole(); TestGetter(); console.X = 5; TestGetter(); void TestGetter() => console.X.Should().Be(System.Console.CursorLeft); }
public ExtractReuters(DirectoryInfo reutersDir, DirectoryInfo outputDir) { this.reutersDir = reutersDir; this.outputDir = outputDir; SystemConsole.WriteLine("Deleting all files in " + outputDir); foreach (FileInfo f in outputDir.EnumerateFiles()) { f.Delete(); } }
public void HaveAnEmptyQueueWhenFlushed() { var console = new SystemConsole(); var data = new ConsoleData("Test Data"); console.BufferData(data); console.Flush(); console.GetBuffered().ShouldBeEmpty(); }
public void BackgroundAutoProperty() { var console = new SystemConsole(); TestGetter(); console.Background = ConsoleColor.DarkBlue; TestGetter(); void TestGetter() => console.Background.Should().Be(System.Console.BackgroundColor); }
public void EmptyBufferOnReset() { var console = new SystemConsole(); var data = new ConsoleData("Test Data"); console.BufferData(data); console.ResetBuffer(); console.GetBuffered().ShouldBeEmpty(); }
public override int DoLogic() { CultureInfo locale = CreateLocale(culture /*language, country, variant*/); RunData.Locale = locale; SystemConsole.WriteLine("Changed Locale to: " + (locale == null ? "null" : (locale.EnglishName.Length == 0) ? "root locale" : locale.ToString())); return(1); }
private void YAutoPropertyTest() { var console = new SystemConsole(); TestGetter(); console.Y = 5; TestGetter(); void TestGetter() => console.Y.Should().Be(System.Console.CursorTop); }
private async Task LoadMavlinkFile(string file) { try { UiDispatcher.RunOnUIThread(() => { SystemConsole.Show(); }); AppendMessage("Loading " + file); ShowStatus("Loading " + file); MavlinkLog data = new MavlinkLog(); await data.Load(file, progress); logs.Add(data); ShowSchema(); Debug.WriteLine(data.StartTime.ToString()); UiDispatcher.RunOnUIThread(() => { foreach (var flight in data.GetFlights()) { flight.Name = "Flight " + allFlights.Count; allFlights.Add(flight); AppendMessage("Motor started at {0} and ran for {1} ", flight.StartTime, flight.Duration); } if (myMap.Visibility == Visibility.Visible) { ShowMap(); } foreach (var text in data.GetStatusMessages()) { SystemConsole.Write(text + "\n"); } ShowTotalFlightTime(); }); // remember successfully loaded log file. Settings settings = await((App)App.Current).LoadSettings(); settings.LastLogFile = file; await settings.SaveAsync(); } catch (Exception ex) { AppendMessage("### Error loading log: " + ex.Message); } ShowStatus("Done Loading " + file); UpdateButtons(); }
private async Task LoadBinaryFile(string file) { try { UiDispatcher.RunOnUIThread(() => { SystemConsole.Show(); }); AppendMessage("Loading " + file); ShowStatus("Loading " + file); Px4DataLog data = new Px4DataLog(); await data.Load(file, progress); logs.Add(data); ShowSchema(); UiDispatcher.RunOnUIThread(() => { // add flights Flight entireLog = new Flight() { Name = "Log " + logs.Count, StartTime = data.StartTime, Duration = data.Duration }; allFlights.Add(entireLog); foreach (var flight in data.GetFlights()) { flight.Name = "Flight " + allFlights.Count; allFlights.Add(flight); AppendMessage("Motor started at {0} and ran for {1} ", flight.StartTime, flight.Duration); } if (myMap.Visibility == Visibility.Visible) { ShowMap(); } ShowTotalFlightTime(); }); // remember successfully loaded log file. Settings settings = await((App)App.Current).LoadSettings(); settings.LastLogFile = file; await settings.SaveAsync(); } catch (Exception ex) { AppendMessage("### Error loading log: " + ex.Message); } ShowStatus("Done Loading " + file); UpdateButtons(); }
public ExtractWikipedia(DocMaker docMaker, DirectoryInfo outputDir) { this.outputDir = outputDir; this.m_docMaker = docMaker; SystemConsole.WriteLine("Deleting all files in " + outputDir); FileInfo[] files = outputDir.GetFiles(); for (int i = 0; i < files.Length; i++) { files[i].Delete(); } }
public YueGeDencrypt2() { Dictionary <string, string> cache = null; // GetCache(Md5Key); Console.WriteLine("-----------------------------"); Console.WriteLine(""); string root = SystemConsole.GetInputStr("输入目标目录:"); if (Directory.Exists(root)) { var folder = Path.GetFileName(root); root += root.EndsWith("\\") ? "" : "\\"; var files = Directory.GetFiles(root, "*.*", SearchOption.AllDirectories) .Select(p => p.Replace(root, "").Replace("\\", "/")) .Where(p => Path.GetFileNameWithoutExtension(p).Length == 32) .ToList(); files.ForEach(file => { File.WriteAllBytes(file + ".temp", UtilSecurity.DecryptionBytes(File.ReadAllBytes(root + file))); }); return; var dirRoot = root.Replace(folder, ""); files.ForEach((file, i, count) => { var path = folder + "/" + file; var newPath = ""; if (cache.TryGetValue(path, out newPath)) { var outPath = dirRoot + newPath; FileHelper.CreateDirectory(outPath); var p = ((float)i / count).ToString("P") + "\t" + path; if (extensionList.Contains(Path.GetExtension(path))) { Console.WriteLine("路径解码中..." + p); File.Copy(root + file, outPath, true); } else { Console.WriteLine("路径解码并文件解密中..." + p); File.WriteAllBytes(outPath, UtilSecurity.DecryptionBytes(File.ReadAllBytes(root + file))); } } else { Console.WriteLine("不存在的资源文件!"); } }); } }
private void ReadLineTest() { var console = new SystemConsole(); using (var s = new StringReader("Testing")) { System.Console.SetIn(s); console.ReadLine().Should().Be("Testing"); } }
public void SetUp() { consoleOut = new StringWriter(); System.Console.SetOut(consoleOut); memory = new Memory(120); console = new SystemConsole(memory, 10, 10, 10); screenSize = (console.Width + Environment.NewLine.Length) * console.Height; }
public override int DoLogic() { Report rp = ReportSumByName(RunData.Points.TaskStats); SystemConsole.WriteLine(); SystemConsole.WriteLine("------------> Report Sum By (any) Name (" + rp.Count + " about " + rp.Reported + " out of " + rp.OutOf + ")"); SystemConsole.WriteLine(rp.Text); SystemConsole.WriteLine(); return(0); }
public override int DoLogic() { TaxonomyReader taxoReader = RunData.GetTaxonomyReader(); RunData.SetTaxonomyReader(null); if (taxoReader.RefCount != 1) { SystemConsole.WriteLine("WARNING: CloseTaxonomyReader: reference count is currently " + taxoReader.RefCount); } taxoReader.Dispose(); return(1); }
public override int DoLogic() { IndexReader reader = RunData.GetIndexReader(); RunData.SetIndexReader(null); if (reader.RefCount != 1) { SystemConsole.WriteLine("WARNING: CloseReader: reference count is currently " + reader.RefCount); } reader.DecRef(); return(1); }
public override int DoLogic() { Report rp = ReportSelectByPrefix(RunData.Points.TaskStats); SystemConsole.WriteLine(); SystemConsole.WriteLine("------------> Report Select By Prefix (" + m_prefix + ") (" + rp.Count + " about " + rp.Reported + " out of " + rp.OutOf + ")"); SystemConsole.WriteLine(rp.Text); SystemConsole.WriteLine(); return(0); }
protected override void Dispose(bool disposing) { if (disposing) { SystemConsole.WriteLine("NRT reopen times:"); for (int i = 0; i < reopenCount; i++) { SystemConsole.Write(" " + reopenTimes[i]); } SystemConsole.WriteLine(); } }
public CheckCard() { var root = SystemConsole.GetInputStr("itemid:") + "\\"; var xx = File.ReadAllLines("itemid.txt").ToList(); xx = xx.AsParallel().Select(p => new List <string>() { string.Format("{0}", p.ToLower()), }).SelectMany(p => p).Where(p => !File.Exists(root + p + ".png")).ToList(); File.WriteAllLines("checkItem.txt", xx); }
private void PrintProps() { SystemConsole.WriteLine("------------> config properties:"); List <string> propKeys = new List <string>(props.Keys); propKeys.Sort(); foreach (string propName in propKeys) { SystemConsole.WriteLine(propName + " = " + props[propName]); } SystemConsole.WriteLine("-------------------------------"); }
static void Main(string[] args) { do { SystemConsole.Run(config: new Dictionary <string, Action>() { { "加密", () => { new YueGeEncrypt(); } }, { "解密", () => { new YueGeDencrypt(); } }, { "解密2", () => { new YueGeDencrypt2(); } } }); } while (SystemConsole.ContinueY()); }
public TaskAgent(A ComputationAgent, Action <R> PayloadObserver = null, Action <IAppMessage> MessageObserver = null) { this.ComputationAgent = ComputationAgent; this.MessageObserver = MessageObserver ?? (message => SystemConsole.Get().Write(message)); this.PayloadObserver = PayloadObserver ?? (payload => { }); this._Task = defer(() => task(() => { iter(Compute(), result => { }); return(Wait()); })); }
public static void Main(string[] args) { FileInfo wikipedia = null; DirectoryInfo outputDir = new DirectoryInfo("./enwiki"); bool keepImageOnlyDocs = true; for (int i = 0; i < args.Length; i++) { string arg = args[i]; if (arg.Equals("--input", StringComparison.Ordinal) || arg.Equals("-i", StringComparison.Ordinal)) { wikipedia = new FileInfo(args[i + 1]); i++; } else if (arg.Equals("--output", StringComparison.Ordinal) || arg.Equals("-o", StringComparison.Ordinal)) { outputDir = new DirectoryInfo(args[i + 1]); i++; } else if (arg.Equals("--discardImageOnlyDocs", StringComparison.Ordinal) || arg.Equals("-d", StringComparison.Ordinal)) { keepImageOnlyDocs = false; } } IDictionary <string, string> properties = new Dictionary <string, string>(); properties["docs.file"] = wikipedia.FullName; properties["content.source.forever"] = "false"; properties["keep.image.only.docs"] = keepImageOnlyDocs.ToString(); Config config = new Config(properties); ContentSource source = new EnwikiContentSource(); source.SetConfig(config); DocMaker docMaker = new DocMaker(); docMaker.SetConfig(config, source); docMaker.ResetInputs(); if (wikipedia.Exists) { SystemConsole.WriteLine("Extracting Wikipedia to: " + outputDir + " using EnwikiContentSource"); outputDir.Create(); ExtractWikipedia extractor = new ExtractWikipedia(docMaker, outputDir); extractor.Extract(); } else { PrintUsage(); } }
private void ObfucatorComplete(string sourceDir, string file, bool embed, bool testLoad) { if (embed) { Stopwatch watch = Stopwatch.StartNew(); SystemConsole.Write("Clean <magenta>{0}<default>...", sourceDir); foreach (string removeFile in Directory.GetFiles(sourceDir, "*.*")) { switch (Path.GetExtension(removeFile).ToLowerInvariant()) { case ".exe": case ".dll": case ".pdb": File.Delete(removeFile); break; } SystemConsole.WriteLine(" {0} <green>ok", StringExtensions.FormatTime(watch.Elapsed)); } } string outFile = FileSystem.Combine(sourceDir, "tmp", Path.GetFileName(file)); if (testLoad) { Stopwatch watch = Stopwatch.StartNew(); SystemConsole.Write("Testing <cyan>{0}<default>...", outFile); try { Assembly.Load(File.ReadAllBytes(outFile)); } catch { SystemConsole.WriteLine(" {0} <red>error", StringExtensions.FormatTime(watch.Elapsed)); throw; } SystemConsole.WriteLine(" {0} <green>ok", StringExtensions.FormatTime(watch.Elapsed)); } File.Delete(file); File.Move(FileSystem.Combine(sourceDir, "tmp", outFile), file); string originalPdb = Path.ChangeExtension(file, ".pdb"); if (File.Exists(originalPdb)) { File.Delete(originalPdb); } string newPdb = FileSystem.Combine(sourceDir, "tmp", Path.ChangeExtension(outFile, ".pdb")); if (File.Exists(newPdb)) { File.Move(newPdb, originalPdb); } }
public void BeforeEach() { _console = new SystemConsole(); }