public async Task Invoke(IMessageContext context, Func <IMessageContext, Task> next) { _debug.Add("Hello from middleware1"); await next(context); _debug.Add("Bye bye from middleware1"); }
public void ExecuteInOrder() { var output = new Output(); var services = new ServiceCollection(); services.AddSingleton(output); services.AddStreamFlow(transport => transport.ConfigureConsumerPipe(builder => { builder.Use(async(context, next) => { output.Add("1"); await next(context); output.Add("4"); }); builder.Use(async(context, next) => { output.Add("2"); await next(context); output.Add("3"); }); builder.Use <MyMiddleware1>(); builder.Use(_ => new MyMiddleware2(output)); })); var provider = services.BuildServiceProvider(); var executor = provider.GetRequiredService <IStreamFlowConsumerPipe>(); executor.ExecuteAsync(provider, null !, _ => { output.Add("The world is mine!"); return(Task.CompletedTask); }); var message = string.Empty; foreach (var line in output.Lines) { if (!string.IsNullOrWhiteSpace(message)) { message += " "; } message += line; _debug.WriteLine(line); } var expected = "1 2 Hello from middleware1 Hello from middleware2 The world is mine! Bye bye from middleware2 Bye bye from middleware1 3 4"; Assert.Equal(expected, message); }
//read the input file... public bool Initialize(string ForceFile) { if (!ReadGrid(ForceFile)) { return(false); } if (!ReadForces_GridFormat(ForceFile)) { return(false); } Force = new double[Dim]; Trilin_Init(); //create output channels, one for each component of the force for (int i = 0; i < Dim; i++) { Output.Add(new Channel("F" + i, this)); } /* * for(double zzz = 0.201; zzz<=0.5; zzz+=0.05) * DumpField_zfix(zzz); //debug! */ return(true); }
private SqlCompilerOutputScope OpenScope(ContextType type) { var container = new ContainerNode(); Output.Add(container); return(OpenScope(type, container)); }
public override void Execute() { AssignmentHelper.RequestInput( this, "Hoeveel leerlingen wil je toevoegen?", out int students ); string[] studentNames = new string[students]; for (int i = 0; i < students; i++) { AssignmentHelper.RequestInput( this, "Wat is de naam van de leerling?", out string studentName ); studentNames[i] = studentName; } string names = String.Join(", ", studentNames); Output.Add($"In totaal hebben we {students} leerlingen met de namen: {names}"); }
protected override void ExecuteTaskLoop() { foreach (var item in Input) { Output.Add(item); } }
public override void Start() { while (true) { byte[] temp = Input.Take(8); if (temp == null) { break; } byte cnt = 0; byte tmp = 0; var lst = new List <byte>(); for (int i = 0; i < temp.Length; i++) { tmp *= 2; tmp += temp[i]; cnt += 1; if (cnt == 8) { lst.Add(tmp); cnt = 0; tmp = 0; } } Output.Add(lst.ToArray()); } }
public MainScanner(string[] words) { Init(words); Console.WriteLine("executing main scanner constructor"); /*Input.Add(new Channel("in0",null)); //0 free input channels * Input.Add(new Channel("in1", null)); //1 * Input.Add(new Channel("in2", null)); //2 * Input.Add(new Channel("in3", null)); //3 * Input.Add(new Channel("in4", null)); //4 * Input.Add(new Channel("amp", null)); //5 amplitude specific channel * Input.Add(new Channel("df", null)); //6 df specific input*/ Output.Add(new Channel("holderx", this)); //0 Output.Add(new Channel("holdery", this)); //1 Output.Add(new Channel("holderz", this)); //2 Output.Add(new Channel("stop", this)); //3? Output.Add(new Channel("cmd", this)); //4 : the code of the currently executed command Output.Add(new Channel("icmd", this)); //5 : the index of the currently executed command Output.Add(new Channel("record", this)); //6 : becomes 1 when scanline records Output.Add(new Channel("scan", this)); //7 : the scanline number //all scanner input are secondary by definition /*for(int i=0;i<Input.Count;i++) * Input[i].Priority=false;*/ }
public override void Execute() { double length = 1.0; double wristCircumference = 1.0; ConsoleKey gender = AssignmentHelper.RequestKey( "Wat is je geslacht?", new[] { ConsoleKey.M, ConsoleKey.F } ); AssignmentHelper.RequestInput(this, "Hoe lang ben je? (in cm)", out double height); int ideal = 0; if (gender == ConsoleKey.M) { ideal = Convert.ToInt32(height - 100); } else if (gender == ConsoleKey.F) { AssignmentHelper.RequestInput(this, "Wat is je pols omtrek? (in cm)", out double circumference); ideal = Convert.ToInt32((length + 4.0 * wristCircumference - 100) / 2); } else { Error = "Onbekend geslacht..."; } Output.Add(""); Output.Add($"Je ideale gewicht is {ideal} kg"); }
public List <T> GetTargetBlocks <T>(ref List <T> Output, string Keyword = null) where T : class { if (Output == null) { Output = new List <T>(); } else { Output.Clear(); } if (localBlocks.Count < 1) { LocalBlocksInit(); } for (int e1 = 0; e1 < localBlocks.Count; e1++) { if ( // localGridFilter(gtsAllBlocks[e1]) && localBlocks[e1] is T && ((Keyword == null) || (Keyword != null && localBlocks[e1].CustomName.StartsWith(Keyword)))) { Output.Add((T)localBlocks[e1]); } } return(Output); }
public DiagnosticChain(ActionCall call) : base(BuildRoute(call)) { if (call.HasInput) { Route.ApplyInputType(call.InputType()); } Tags.Add(NoTracing); RouteName = call.HandlerType.Name.Replace("FubuDiagnostics", "") + ":" + call.Method.Name.Replace("get_", "").Replace("post_", "").Replace("{", "").Replace("}", ""); AddToEnd(call); if (call.HasInput) { Input.Add(new NewtonsoftJsonFormatter()); } if (call.HasOutput && call.OutputType() != typeof(HtmlTag) && !call.OutputType().CanBeCastTo <HtmlDocument>()) { var writerType = typeof(DiagnosticJsonWriter <>).MakeGenericType(call.OutputType()); var writer = Activator.CreateInstance(writerType).As <IMediaWriter>(); Output.Add(writer); } }
public override void Start() { while ((Input.Count > 0) | (Input.IsOpen)) { if (token.token) { break; } byte[] temp = Input.Take(8); if (temp == null) { break; } byte cnt = 0; byte tmp = 0; var lst = new List <byte>(); for (int i = 0; i < temp.Length; i++) { tmp *= 2; tmp += temp[i]; cnt += 1; if (cnt == 8) { lst.Add(tmp); cnt = 0; tmp = 0; } } Output.Add(lst.ToArray()); } Output.Complete(); // Console.WriteLine(Debug.i.ToString()); }
public void writeLineOutput(int currentExposition, Program currentProgram) { /* This variable keeps data from an exposition to only one program on the list, being them: * program name participant name date hour exposition hour hit time(ms) interval(ms) interval should be(ms) * exposition accumulative timeexposition time(ms) number of sequency type of stimulus shape of stimulus * stimulus color */ string programType = null; if (currentProgram.GetType() == typeof(StroopProgram)) { programType = "StroopTest"; } else if (currentProgram.GetType() == typeof(ReactionProgram)) { programType = "ReactionTest"; } else if (currentProgram.GetType() == typeof(MatchingProgram)) { programType = "MatchingTest"; } string[] currentParticipant = participant(); var text = programInUse.Name + "\t" + currentProgram.ProgramName + "\t" + programType + "\t" + currentParticipant[0] + "\t" + currentParticipant[1] + "\t" + initialDate.Day + "/" + initialDate.Month + "/" + initialDate.Year + "\t" + initialDate.Hour + ":" + initialDate.Minute + ":" + initialDate.Second + ":" + initialDate.Millisecond.ToString() + "\t" + ExpositionTime.Hour + ":" + ExpositionTime.Minute + ":" + ExpositionTime.Second + ":" + ExpositionTime.Millisecond.ToString() + "\t" + currentExposition; Output.Add(text); }
private bool Initialize(string ForceFile) { if (!ReadGrid(ForceFile)) { return(false); } if (!ReadForces_GridFormat(ForceFile)) { return(false); } Force = new double[3]; Bicubic_Init(); f0 = new double[Dim]; f1 = new double[Dim]; //create output channels, one for each component of the force for (int i = 0; i < Dim; i++) { Output.Add(new Channel("F" + i, this)); } //DumpField_zfix(0.55); //debug! return(true); }
public override System.Threading.Tasks.Task TimerTickedAsync() { if (Status == null || Status.IsRunning == false) { return(null); } TaskStatus = TaskStatus.Started; return(ApplicationModel.DatabaseCommands.GetAsync(BackupStatus.RavenBackupStatusDocumentKey) .ContinueOnSuccessInTheUIThread(item => { var documentConvention = ApplicationModel.Current.Server.Value.Conventions; Status = documentConvention.CreateSerializer().Deserialize <BackupStatus>(new RavenJTokenReader(item.DataAsJson)); Output.Clear(); foreach (var backupMessage in Status.Messages) { Output.Add("[" + backupMessage.Timestamp + "] "+ backupMessage.Severity + " : " + backupMessage.Message); } if (Status.Completed != null) { TaskStatus = TaskStatus.Ended; } })); }
public List <IMyTerminalBlock> GetTargetBlocks <T>(ref List <IMyTerminalBlock> Output, string Keyword = null) where T : class { if (gtsAllBlocks.Count < 1) { gridsInit(); } if (Output == null) { Output = new List <IMyTerminalBlock>(); } else { Output.Clear(); } if (localBlocks.Count < 1) { LocalBlocksInit(); } // sInitResults += "\nFound " + localBlocks.Count + " total blocks"; for (int e1 = 0; e1 < localBlocks.Count; e1++) { if ( // localGridFilter(gtsAllBlocks[e1]) && localBlocks[e1] is T && ((Keyword == null) || (Keyword != null && localBlocks[e1].CustomName.StartsWith(Keyword)))) { Output.Add(localBlocks[e1]); } } return(Output); }
private void Append(string s) { //s = string.IsNullOrWhiteSpace(s) ? string.Empty : s; if (s == " ") { // do not add just a single space after the // comment, ever if (LastType == "TK_COMMENT") { AppendNewline(); return; } // make sure only single space gets drawn if (Flags.EatNextSpace) { Flags.EatNextSpace = false; } else if (Output.Count != 0 && Output[Output.Count - 1] != " " && Output[Output.Count - 1] != "\n" && Output[Output.Count - 1] != IndentString) { Output.Add(" "); } } else { JustAddedNewline = false; Flags.EatNextSpace = false; Output.Add(s); } }
public AsyncInvoker() { Timer slowTimer = new Timer(OnTimeInterval, "slow", 2500, 2500); Timer fastTimer = new Timer(OnTimeInterval, "fast", 2000, 2000); Output.Add("method"); }
protected override void DoWork(string item) { foreach (string shifted in Shift(item)) { Output.Add(shifted); } }
public override void Execute() { Output.Add("De invoer moet gescheiden zijn met een comma."); ShowOutput(); AssignmentHelper.RequestInput( this, "Voer de getallen in die je wilt gebruiken.", out string input ); string[] split = input.Split(','); int[] values = Array.ConvertAll(split, int.Parse); AssignmentHelper.RequestInput( this, $"Welke index wil je opvragen? (van 0 tot {values.Length - 1})", out int index ); if (index < 0) { Error = "Kan index lager als 0 niet opvragen."; return; } if (index > values.Length) { Error = "Kan index niet opvragen."; return; } Output.Add($"De waarde van index {index} is {values[index]}"); }
public override void SetUp() { Input.Add(new Channel("x0", null)); //the reference point n = (int)GetInitParameter(InitWords, "n", true); for (int i = 0; i < n; i++) { Input.Add(new Channel("f" + i.ToString(), null)); } for (int i = 0; i < n; i++) { Input.Add(new Channel("eta" + i.ToString(), null)); } for (int i = 0; i < n; i++) { Output.Add(new Channel("x" + (i + 1).ToString(), this)); } x = new double[n + 1]; v = new double[n + 1]; a = new double[n + 1]; InputDefaultInit(); //x=0; xo=0; xoo=0; v = 0; a = 0; }
public override void Execute() { IDictionary <string, string> dictionary = new Dictionary <string, string> { { "nl", "Tot ziens!" }, { "fr", "Au revoir!" }, { "frl", "Oant sjens!" }, { "en", "Bye!" }, { "de", "Tschuess" } }; Output.Add("In welke taal moet het woordje `tot ziens` worden weer gegeven?"); Output.Add("De opties zijn: Nederlands(NL), Engels(EN), Fries(FRL) en Frans(FR)"); AssignmentHelper.RequestInput(this, "Typ de twee of driecijferige code in", out string language); string result = ""; if (dictionary.TryGetValue(language.ToLower(), out result)) { Output.Add($"Tot ziens in {language.ToUpper()} is {result}"); } else { Output.Add("Onbekende taal :("); } }
public static void CaptureWinners(string[] winners) { StreamWriter output = null; lock (Output) { if (!Output.TryGetValue(-1, out output)) { output = File.CreateText(Path.Combine(TrainingPath, string.Format("{0:yyyy-MM-dd_hh-mm-ss}.winner", Start))); Output.Add(-1, output); } } var sb = new StringBuilder(); sb.Append('['); for (int i = 0; i < winners.Length; i++) { sb.AppendFormat("\"{0}\"", winners[i]); if (i < winners.Length - 1) { sb.Append(','); } } sb.Append(']'); var json = sb.ToString(); output.WriteLine(json); }
public override void SetUp () { string ForceFile = GetInitParameterString(InitWords,"file",true); //get the forcefield file //count the force points if(!CountPoints(ForceFile, out GridSize)) throw new Exception(string.Format("ERROR! Circuit {0} (1D Field Linear Interpolator) not correctly initlized.", Name)); //read grid parameters if(!ReadGrid(ForceFile)) throw new Exception(string.Format("ERROR! Circuit {0} (1D Field Linear Interpolator) not correctly initlized.", Name)); //make the grid MakeGrid(); //read the data in if(!ReadForces_GridFormat(ForceFile)) throw new Exception(string.Format("ERROR! Circuit {0} (1D Field Linear Interpolator) not correctly initlized.", Name)); //make output channels for(int i=0; i<Dim; i++) Output.Add(new Channel("F"+i.ToString(),this)); InputDefaultInit(); Console.WriteLine("Circuit {0} (1D Field Linear Interpolator) created.", Name); }
public randomg(string[] words) { Init(words, 1, 1); Output.Add(new Channel("out", this)); Console.WriteLine("Gaussian Random number generator {0} created.\n", Name); }
public override void Start() { //debug int cnt = 0; //debug while (true) { byte[] temp = Input.Take(); if (temp == null) { break; } byte[] result = new byte[temp.Length * 8]; for (int i = 0; i < temp.Length; i++) { byte m = temp[i]; for (int j = 7; j >= 0; j--) { result[i * 8 + j] = (byte)(m % 2); m = (byte)(m / 2); } } Output.Add(result); } Output.Complete(); }
public void Run() { if (Input.Count != 2) { throw new ArgumentException("Incorrect or lack of assigned value in local variable"); } string[] variables = Input[0].Trim().Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); string value = Input[1].Trim(); for (int i = 0; i < variables.Length; i++) { variables[i] = variables[i].Trim(); if (variables[i][0] != '$') { throw new ArgumentException("Incorrect \"" + Name + "\""); } try { Variables.Add(variables[i], value); } catch (ArgumentException) { Variables[variables[i]] = value; } } Output.Add(value); }
/// <summary> /// Running logic of the Gulu. /// </summary> /// <param name="_param">The filename that is going to be processed.</param> /// <returns>True if succeed. False if it failed.</returns> public override bool Execute(string _param) { try { Output.Add(string.Format(Resources.TEXT_PROCESSING, _param)); FileStream fileStream = File.OpenWrite(_param); StreamWriter writer = new StreamWriter(fileStream); numOfBlocks__ = fileStream.Length / BlockSize; remaining__ = fileStream.Length % BlockSize; for (long i = 0; i < numOfBlocks__; i++) { writer.Write(block__); } if (remaining__ > 0) { char[] remainingBlock = new char[remaining__]; Array.Clear(remainingBlock, 0, (int)remaining__); writer.Write(remainingBlock); } writer.Flush(); writer.Close(); fileStream.Close(); File.Delete(_param); return(true); } catch (Exception ex) { Output.Add(ex.Message); return(false); } }
public override void SetUp() { Input.Add(new Channel("signal", null)); Output.Add(new Channel("tick", this)); //0: gets to 1 if the digital signal raises InputDefaultInit(); }
public Mesh CreateOrUpdateMesh() { int triangleCount = Output.Count / 2; int centerVertexId = Output.Count; Output.Add(Center); List <int> triangles = new List <int>(triangleCount); Gizmos.color = Color.yellow; for (int i = 0; i < triangleCount; i++) { triangles.Add(centerVertexId); triangles.Add(i * 2 + 1); triangles.Add(i * 2 + 0); } List <Vector2> lightUvs = new List <Vector2>(); List <Vector3> normals = new List <Vector3>(); List <Color> colors = new List <Color>(); float invSize = 1 / Size; Vector2 half = Vector2.one * 0.5f; foreach (Vector2 vector2 in Output) { lightUvs.Add((-vector2 + Center) * invSize + half); normals.Add(Vector3.up); colors.Add(Color); } Mesh mesh = _mesh; if (mesh != null) { //if (mesh.triangles.Length != triangles.Count) //{ // UnityEngine.Object.Destroy(mesh); // mesh = new Mesh(); //} mesh.triangles = null; mesh.vertices = null; mesh.colors = null; mesh.uv = null; mesh.uv2 = null; } else { mesh = new Mesh(); } _mesh = mesh; //mesh.name = "My shadow mesh"; mesh.vertices = Output.Select(o => (Vector3)(o - Center)).ToArray(); mesh.triangles = triangles.ToArray(); mesh.uv2 = lightUvs.ToArray(); mesh.colors = colors.ToArray(); mesh.normals = normals.ToArray(); mesh.RecalculateBounds(); UpdateUvs(); return(mesh); }