//Shows request and options to the user and returns selected option //location controls which screen the request and/or options are displayed on but is ignored since only output is the console //clear controls whether or not the clear before displaying request and/or options public override string GetOption(OutputLocation location, string request, string[] options, bool clear) { //Rerequest until option is picked while (true) { if (clear) { Console.Clear(); } Console.WriteLine(request + ":"); for (int i = 1; i <= options.Length; i++) { //Numbers are shifted up by one but options are not, this is to avoid displaying 0 as an option Console.WriteLine(i + " : " + options[i - 1]); } //Returns if input is a number between 1 and option.Length if (int.TryParse(Input.ReadLine(), out int input) && input > 0 && input - 1 < options.Length) { //Options 0 to options.length - 1 are displayed as 1 to options.length so 1 needs to be removed to line up with options return(options[input - 1]); } } }
public void VisitChunk(IChunkVisitor visitor, OutputLocation location, IList <Chunk> chunks, StringBuilder output) { if (location == OutputLocation.UsingNamespace) { output.AppendLine("//this was a test"); } }
public void VisitChunk(IChunkVisitor visitor, OutputLocation location, IList <Chunk> body, StringBuilder output) { switch (location) { case OutputLocation.ClassMembers: output .Append("global::System.Action __target_") .Append(_targetExtensionCount) .AppendLine(";"); break; } visitor.Accept(body); }
public void VisitChunk(IChunkVisitor visitor, OutputLocation location, IList<Chunk> body, StringBuilder output) { switch (location) { case OutputLocation.ClassMembers: output .Append("global::System.Action __target_") .Append(_targetExtensionCount) .AppendLine(";"); break; } visitor.Accept(body); }
public void VisitChunk(IChunkVisitor visitor, OutputLocation location, IList<Chunk> body, StringBuilder output) { if (location == OutputLocation.ClassMembers) { foreach (var snippet in body.OfType<CodeStatementChunk>().SelectMany(chunk => chunk.Code)) { snippet.Value = snippet.Value.Replace("@class", "class"); } var source = new SourceWriter(new StringWriter(output)); var generator = new GeneratedCodeVisitor(source, new Dictionary<string, object>(), NullBehaviour.Strict); generator.Accept(body); } }
public void VisitChunk(IChunkVisitor visitor, OutputLocation location, IList <Chunk> body, StringBuilder output) { if (location == OutputLocation.ClassMembers) { foreach (var snippet in body.OfType <CodeStatementChunk>().SelectMany(chunk => chunk.Code)) { snippet.Value = snippet.Value.Replace("@class", "class"); } var source = new SourceWriter(new StringWriter(output)); var generator = new GeneratedCodeVisitor(source, new Dictionary <string, object>(), NullBehaviour.Strict); generator.Accept(body); } }
public override void Reset() { SelectParameters?.Reset(); OutputLocation?.Reset(); Days = 0; GlacierTier = RetrievalTier.Unknown; RequestTier = RetrievalTier.Unknown; RequestType = RestoreRequestType.Unknown; Description = null; RequestPayer = Payer.Unknown; VersionId = null; base.Reset(); }
private static TextWriter GetOutputLocation(OutputLocation location) { switch (location) { case OutputLocation.StdOutput: return(Console.Out); case OutputLocation.StdError: return(Console.Error); default: throw new ArgumentException($"Invalid location {location}", nameof(location)); } }
public void VisitChunk(IChunkVisitor visitor, OutputLocation location, IList <Chunk> body, StringBuilder output) { if (location == OutputLocation.RenderMethod) { output.AppendFormat("RenderComponent(\"{0}\", new System.Collections.Generic.Dictionary<string,object> {{", node.Name); var delimiter = ""; foreach (var attribute in node.Attributes) { var code = attribute.AsCode(); output.AppendFormat("{2}{{\"{0}\",{1}}}", attribute.Name, code, delimiter); delimiter = ", "; } output.AppendLine("}, new System.Action(delegate {"); visitor.Accept(body); //only append body if there are no sections output.AppendLine("}),"); output.AppendLine("new System.Collections.Generic.Dictionary<string,System.Action> {"); foreach (var section in sectionsChunks) { output.Append("{\"") .Append(section.Key) .AppendLine("\", new System.Action(delegate {"); foreach (var attr in sectionsAttributes[section.Key]) { output.Append("var ") .Append(attr.Name) .Append("=(") .Append(attr.AsCode()) .Append(")ViewData[\"") .Append(attr.Name) .AppendLine("\"];"); } visitor.Accept(section.Value); output.AppendLine("})},"); } output.AppendLine("});"); } else { visitor.Accept(body); foreach (var sectionChunks in sectionsChunks.Values) { visitor.Accept(sectionChunks); } } }
public void VisitChunk(IChunkVisitor visitor, OutputLocation location, IList<Chunk> body, StringBuilder output) { if (location == OutputLocation.RenderMethod) { output.AppendFormat("RenderComponent(\"{0}\", new System.Collections.Generic.Dictionary<string,object> {{", node.Name); var delimiter = ""; foreach (var attribute in node.Attributes) { var code = attribute.AsCode(); output.AppendFormat("{2}{{\"{0}\",{1}}}", attribute.Name, code, delimiter); delimiter = ", "; } output.AppendLine("}, new System.Action(delegate {"); visitor.Accept(body); //only append body if there are no sections output.AppendLine("}),"); output.AppendLine("new System.Collections.Generic.Dictionary<string,System.Action> {"); foreach (var section in sectionsChunks) { output.Append("{\"") .Append(section.Key) .AppendLine("\", new System.Action(delegate {"); foreach (var attr in sectionsAttributes[section.Key]) { output.Append("var ") .Append(attr.Name) .Append("=(") .Append(attr.AsCode()) .Append(")ViewData[\"") .Append(attr.Name) .AppendLine("\"];"); } visitor.Accept(section.Value); output.AppendLine("})},"); } output.AppendLine("});"); } else { visitor.Accept(body); foreach(var sectionChunks in sectionsChunks.Values) visitor.Accept(sectionChunks); } }
public FormOutput() { InitializeComponent(); BindConsole(); //读取位置坐标 try { OutputLocation location = XmlHelper.Deserialize <OutputLocation>(Path.Combine(Application.StartupPath, ConfigNames.OutputLocation)); if (location != null) { this.Location = new Point(location.X, location.Y); } else { this.StartPosition = FormStartPosition.CenterScreen; } } catch { } }
//Display list of options to user and returns picked option public override string GetOption(OutputLocation location, string request, string[] options, bool clear) { //Rerequest until option is picked while (true) { //Console should only be cleared if it us being used and it has been requested if (clear && location != OutputLocation.Secondary) { Console.Clear(); } if (location != OutputLocation.Console) { //Lcd must be cleared if being used, may write to wrong row otherwise SecondaryDisplay.Clear(); SecondaryDisplay.WriteLine(request); SecondaryDisplay.Write("Back: * "); } int selectedOption; //Write request + options to console and write request to secondary display if using it if (location != OutputLocation.Secondary) { //Write request to console and finish secondary display setup Console.WriteLine(request + ':'); if (location != OutputLocation.Console) { SecondaryDisplay.Write("Enter: #"); SecondaryDisplay.CursorLeft = 0; } //Write options to console for (int i = 1; i <= options.Length; i++) { //Numbers are shifted up by one but options are not, this is to avoid displaying 0 as an option Console.WriteLine(i + " : " + options[i - 1]); } //Options 0 to options.length - 1 are displayed as 1 to options.Length so 1 needs to be removed to line up with options selectedOption = int.Parse(Input.ReadLine()) - 1; } else { selectedOption = 0; SecondaryDisplay.Write("Begin: #"); //Get number from user ConsoleKeyInfo inputChar = Input.ReadKey(true, InputType.Numbers); //only continue if char is enter while (inputChar.Key != ConsoleKey.Enter) { inputChar = Input.ReadKey(true, InputType.Numbers); } bool selecting = true; //Show options to user until selection has been made while (selecting) { //Clear line and write option SecondaryDisplay.CursorLeft = 0; SecondaryDisplay.Write(options[selectedOption].PadRight(SecondaryDisplay.DisplaySize.Width)); //Get direction for user inputChar = Input.ReadKey(true, InputType.Arrows); //Move between options if left or right arrow was pressed, stop and continue fuction if enter was pressed switch (inputChar.Key) { case ConsoleKey.LeftArrow when selectedOption > 0: selectedOption--; break; case ConsoleKey.RightArrow when selectedOption < options.Length - 1: selectedOption++; break; case ConsoleKey.Enter: selecting = false; break; } } } //Return if input is a number between 0 and option.Length - 1, restart otherwise if (selectedOption >= 0 && selectedOption < options.Length) { return(options[selectedOption]); } } }
public void VisitChunk(IChunkVisitor visitor, OutputLocation location, IList<Chunk> body, StringBuilder output) { visitor.Accept(body); }
public void VisitChunk(IChunkVisitor visitor, OutputLocation location, IList <Chunk> body, StringBuilder output) { visitor.Accept(body); }
public ConsoleLog(OutputLocation location) : base(GetOutputLocation(location)) { }
public void VisitChunk(IChunkVisitor visitor, OutputLocation location, IList<Chunk> chunks, StringBuilder output) { if (location == OutputLocation.UsingNamespace) output.AppendLine("//this was a test"); }
//Shows request and options to the user and returns selected option //location controls which screen the request and/or options are displayed on //clear controls whether or not to clear the location display before displaying request and/or options public abstract string GetOption(OutputLocation location, string request, string[] options, bool clear);
public void VisitChunk(IChunkVisitor visitor, OutputLocation location, IList<Chunk> body, StringBuilder output) { //when we need to accept chunks? if (location == OutputLocation.RenderMethod) visitor.Accept(_mChunks); }