public void Test(SharpNeat.Phenomes.IBlackBox box, IList <double> inputs, OutputProcessor fun) { var outputs = new double[nbOutputsNN]; activate(box, inputs, outputs); var clustersOutputs = GetOutputValuePerCluster(outputs); for (int i = 0; i < nbClusters; i++) { fun(i, clustersOutputs[i]); } }
internal static void RemoveData <T>(OutputProcessor sessionHolder, string sessionID) { SessionProvider session; if (!sessionHolder.Sessions.TryGetValue(sessionID, out session)) { //there is nothing to remove return; } //TODO remove session itself, if needed session._dataStorage.Remove(typeof(T)); }
public static string GetPayslip(string input) { var inputProcessor = new InputProcessor(); var payslipGenerator = new PayslipCalculator(); var outputProcessor = new OutputProcessor(); //InputProcessor will split the required Input from string payslipInput = inputProcessor.Process(input); //Payslip Generator internally will calculate tax and create tax table to prepare payslip payslipInfo = payslipGenerator.Calculate(payslipInput); //OutputProcessor will join the output in string return(outputProcessor.Process(payslipInfo)); }
internal static string GetFlash(OutputProcessor sessionHolder, string sessionID, string messageID) { SessionProvider session; if (!sessionHolder.Sessions.TryGetValue(sessionID, out session)) { //there is no session with possible flash return(null); } string value; session._flashStorage.TryGetValue(messageID, out value); return(value); }
internal static void FlipFlash(OutputProcessor sessionHolder, string sessionID) { SessionProvider session; if (!sessionHolder.Sessions.TryGetValue(sessionID, out session)) { //there is nothing to flip return; } var xchgTmp = session._flashStorage; session._flashStorage = session._flashFlip; session._flashFlip = xchgTmp; xchgTmp.Clear(); }
public void Success_CorrectlyFormatsOutputOfValidItem() { // Setup const string expectedName = "MyItem"; const int expectedSellIn = 49; const int expectedQuality = 78; bool result; byte[] buffer; using (var stream = new MemoryStream()) { using (var streamWriter = new StreamWriter(stream)) { var processor = new OutputProcessor(streamWriter); var item = new Item(expectedName, expectedSellIn, expectedQuality, QualityStrategy.Stable, ShelfLifeStrategy.Stable); // Execution result = processor.Process(item); } // Get the contents of the stream buffer = stream.GetBuffer(); } // Assert Assert.IsTrue(result); using (var memoryStream = new MemoryStream(buffer)) { using (var reader = new StreamReader(memoryStream)) { var line = reader.ReadLine(); // Assert var expectedString = $"{expectedName} {expectedSellIn} {expectedQuality}"; Assert.IsNotNull(line); Assert.AreEqual(expectedString, line); } } }
public void PayslipCalculatorTest() { string Input = "David,Rudd,60050,9%,01 March – 31 March"; string Expected = "David Rudd,01 March – 31 March,5004,922,4082,450"; string Actual; PayslipInput payslipInput; PayslipInfo payslipInfo; var inputProcessor = new InputProcessor(); var payslipCalculator = new PayslipCalculator(); var outputProcessor = new OutputProcessor(); payslipInput = inputProcessor.Process(Input); payslipInfo = payslipCalculator.Calculate(payslipInput); Actual = outputProcessor.Process(payslipInfo); Assert.AreEqual(Expected, Actual); }
private void onKeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.NumPad0) { GTA.UI.Screen.ShowNotification("Starting..."); Game.Player.Character.Weapons.RemoveAll(); new WepShopProcessor("shopdata/"); new WeaponMetaProcessor(@"gameinfo/weapons.meta", @"gameinfo/weaponcomponents.meta"); MissingAttachmentsProcessor.Process(); WeaponInfoProcessor.Process(); OutputProcessor.OutputDataFile(@"output/weaponData.json", OutputProcessor.MakeOutputPayload(WeaponStorage.weaponData)); GTA.UI.Screen.ShowNotification("~g~weaponData.json created!"); } }
public static void WriteOutputToFile() { string result = OutputProcessor.Process(schedules); if (!string.IsNullOrEmpty(result)) { string Directory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location); string OutPutFile = @"" + Directory; using (FileStream fs = File.OpenWrite((GetFilePath(false)))) { Byte[] info = new UTF8Encoding(true).GetBytes(result); fs.Write(info, 0, info.Length); byte[] newline = Encoding.ASCII.GetBytes(Environment.NewLine); fs.Write(newline, 0, newline.Length); } } }
public void VerifyArgumentPositivelScenario() { //Arrange var outputProcessor = new OutputProcessor(); var payments = new PaymentDetails { MonthlyPayment = 454.23m, TotalInterest = 83523.23m, TotalPayment = 163523.23m }; //Act var result = outputProcessor.Process(payments); //Assert Assert.Equal("{" + Environment.NewLine + " \"monthly payment\": 454.23," + Environment.NewLine + " \"total interest\": 83523.23," + Environment.NewLine + " \"total payment\": 163523.23" + Environment.NewLine + "}", result); }
/// <summary> /// 异常处理 /// </summary> /// <param name="request"></param> /// <param name="responseModel"></param> /// <param name="ex"></param> /// <returns></returns> private string GetErrorContent(RequestModelType request, ApiResponseModelBase responseModel, Exception ex) { string custError = GetCustomErrorOutput(request, responseModel, ex); if (custError != NoCustomOutputFun) { return(custError); } //responseModel.respTime = DateTime.Now; var resp = GetUnSuccessResponseModel(responseModel); if (resp == null) { return(OutputProcessor.OutPut <ApiResponseModelBase>(responseModel, IgnoreList)); } else { return(OutputProcessor.OutPut <ResponseModelType>(resp, IgnoreList)); } }
private void OnKeyUp(object sender, KeyEventArgs e) { /* * if (e.KeyCode == Keys.NumPad4) * { * foreach (var weapon in Enum.GetValues(typeof(WeaponHash))) * { * Game.Player.Character.Weapons.Give((WeaponHash) weapon, 100, true, true); * } * * } * if (e.KeyCode == Keys.NumPad2) * { * Vehicle veh = World.CreateVehicle((VehicleHash) Game.GenerateHash(Game.GetUserInput()), * Game.Player.Character.Position + Game.Player.Character.ForwardVector * 3.0f, * Game.Player.Character.Heading); * veh.PlaceOnGround(); * }*/ if (e.KeyCode == Keys.NumPad1) { if (string.IsNullOrEmpty(languageCode)) { languageCode = Game.GetUserInput("en"); } Notification.Show("~y~Starting..."); VehicleLoader.LoadVehicles(); ModAssignProcessor.Process(); LocalizationProcessor.Process(); CleanupProcessor.Process(); OutputProcessor.OutputVehicleInfo(); Notification.Show("~g~Finished!"); } }
static void Main(string[] args) { Console.WriteLine("Please enter input file path:"); string filePath = Console.ReadLine(); if (String.IsNullOrEmpty(filePath) || !File.Exists(filePath)) { Console.WriteLine("Invalid file path"); Console.ReadLine(); return; } try { InputProcessor ip = new InputProcessor(filePath); Conference conference = ip.GetConference(); if (conference.TalksToSchedule.Count == 0) { Console.WriteLine("No talks found. Please add valid talks"); Console.ReadLine(); return; } conference.Schedule(); OutputProcessor op = new OutputProcessor(conference); string output = op.Process(); Console.WriteLine(output); } catch (Exception ex) { Console.WriteLine("An Error occurred: ", ex.Message); } finally { Console.ReadLine(); } }
static void Main(string[] args) { string Directory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location); bool InputFileFound = false; string[] Inputs = null; //This input can be taken from user int NumberOfTracks = 2; try { Inputs = System.IO.File.ReadAllLines(GetFilePath(true)); InputFileFound = true; } catch (Exception ex) { Console.WriteLine("Input file - " + ex.Message.ToString()); InputFileFound = false; } if (InputFileFound) { List <Track> Tracks = new List <Track> { }; InputProcessor inputProcessor = new InputProcessor(Inputs, NumberOfTracks); Tracks = inputProcessor.Process(); OutputProcessor outputProcessor = new OutputProcessor(Tracks); Outputs = outputProcessor.Process(); if (Outputs.Count > 1) { WriteOutputToFile(); } Console.WriteLine("Output file is available at " + GetFilePath(false)); } Console.ReadLine(); }
public void Success_CorrectlyFormatsOutputOfNullItem() { // Setup var result = false; byte[] buffer; using (var stream = new MemoryStream()) { using (var streamWriter = new StreamWriter(stream)) { var processor = new OutputProcessor(streamWriter); // Execution result = processor.Process(null); } // Get the contents of the stream buffer = stream.GetBuffer(); } // Assert Assert.IsFalse(result); using (var memoryStream = new MemoryStream(buffer)) { using (var reader = new StreamReader(memoryStream)) { var line = reader.ReadLine(); // Assert var expectedString = "NO SUCH ITEM"; Assert.IsNotNull(line); Assert.AreEqual(expectedString, line); } } }
public string GetChart() { Dictionary <string, string> summary = new Dictionary <string, string>(); Int64 total = 0; Int64 duration = 0; foreach (Latency.TranProcessingTime_Sec lb in list) { total += lb.TranCommits; duration += lb.Sum_Duration; } summary.Add("Total Transaction Processed", total.ToString()); summary.Add("Transaction Commit Avg Duration", ((1.0 * duration) / total).ToString("F") + " ms"); string sumHtml = OutputProcessor.ConvertDictionaryToHTMLTable(summary); Controller.latencySummaryDict.Add("Transaction Processing (db=" + dbid + ")", (int)(duration / total)); Dictionary <string, List <string> > dict = new Dictionary <string, List <string> >(); /*Date.UTC(1970, 10, 25,10,20,55), 1*/ List <string> Avg_Duration = new List <string>(); foreach (Latency.TranProcessingTime_Sec lb in list) { string str = "Date.UTC(" + lb.EventTimeStamp.Year.ToString() + "," + lb.EventTimeStamp.Month.ToString() + "," + lb.EventTimeStamp.Day.ToString() + "," + lb.EventTimeStamp.Hour.ToString() + "," + lb.EventTimeStamp.Minute.ToString() + "," + lb.EventTimeStamp.Second.ToString() + ")," + lb.Avg_Duration; Avg_Duration.Add(str); } dict.Add("Avg_Duration", Avg_Duration); Controller.AddChartData("Trans processing (db=" + dbid + ")", Avg_Duration); Dictionary <string, List <string> > dict2 = new Dictionary <string, List <string> >(); List <string> trans = new List <string>(); foreach (Latency.TranProcessingTime_Sec lb in list) { string str = "Date.UTC(" + lb.EventTimeStamp.Year.ToString() + "," + lb.EventTimeStamp.Month.ToString() + "," + lb.EventTimeStamp.Day.ToString() + "," + lb.EventTimeStamp.Hour.ToString() + "," + lb.EventTimeStamp.Minute.ToString() + "," + lb.EventTimeStamp.Second.ToString() + ")," + lb.TranCommits; trans.Add(str); } dict2.Add("TransCommit", trans); string chartHtml = Output.HighCharts.GetChartHtml("Transaction Processing Avg Duration Per Second", title, "Time", "Duration (ms)", dict, "#005c99"); string chartHtml2 = Output.HighCharts.GetChartHtml(" Transaction Processing Sum Per Second", title, "Time", "Transactions Processing", dict2, "#408000"); return(sumHtml + "<br>" + chartHtml + "<br>" + chartHtml2); }
public string GetChart() { Dictionary <string, string> summary = new Dictionary <string, string>(); Int64 total = 0; Int64 duration = 0; foreach (Latency.LogBlockFlush_Sec lb in list) { total += lb.LogBlocks; duration += lb.Sum_Duration; } summary.Add("Total Log Blocks Processed", total.ToString()); summary.Add("Log Blocks Avg Harden Duration", ((1.0 * duration) / total).ToString("F") + " ms"); string sumHtml = OutputProcessor.ConvertDictionaryToHTMLTable(summary); if (repl == Replica.Primary) { Controller.latencySummaryDict.Add("Primary Log Harden (db=" + dbid + ")", (int)(duration / total)); } else { Controller.latencySummaryDict.Add("Secondary Log Harden (db=" + dbid + ")", (int)(duration / total)); } Dictionary <string, List <string> > dict = new Dictionary <string, List <string> >(); /*Date.UTC(1970, 10, 25,10,20,55), 1*/ List <string> Avg_Duration = new List <string>(); foreach (Latency.LogBlockFlush_Sec lb in list) { string str = "Date.UTC(" + lb.EventTimeStamp.Year.ToString() + "," + lb.EventTimeStamp.Month.ToString() + "," + lb.EventTimeStamp.Day.ToString() + "," + lb.EventTimeStamp.Hour.ToString() + "," + lb.EventTimeStamp.Minute.ToString() + "," + lb.EventTimeStamp.Second.ToString() + ")," + lb.Avg_Duration; Avg_Duration.Add(str); } dict.Add("Avg_Duration", Avg_Duration); if (repl == Replica.Primary) { Controller.AddChartData("Primary Log Harden (db=" + dbid + ")", Avg_Duration); } else { Controller.AddChartData("Secondary Log Harden (db=" + dbid + ")", Avg_Duration); } Dictionary <string, List <string> > dict2 = new Dictionary <string, List <string> >(); List <string> logBlocks = new List <string>(); foreach (Latency.LogBlockFlush_Sec lb in list) { string str = "Date.UTC(" + lb.EventTimeStamp.Year.ToString() + "," + lb.EventTimeStamp.Month.ToString() + "," + lb.EventTimeStamp.Day.ToString() + "," + lb.EventTimeStamp.Hour.ToString() + "," + lb.EventTimeStamp.Minute.ToString() + "," + lb.EventTimeStamp.Second.ToString() + ")," + lb.LogBlocks; logBlocks.Add(str); } dict2.Add("LogBlocks", logBlocks); string chartHtml = Output.HighCharts.GetChartHtml("Log Block Local Harden Avg Duration Per Second", title, "Time", "Duration (ms)", dict, "#005c99"); string chartHtml2 = Output.HighCharts.GetChartHtml(" Log Blocks Sum Per Second", title, "Time", "Log Blocks", dict2, "#408000"); return(sumHtml + "<br>" + chartHtml + "<br>" + chartHtml2); }
/// <summary> /// The main program entry point /// </summary> /// <param name="args">Command line arguments</param> static async Task <int> Main(string[] args) { // We require two arguments, one for the input file and the other for the output file. If we don't have these // we must stop if (args.Length != 2) { Console.WriteLine("Usage: GuildedRose InputFileName OutputFileName"); Console.WriteLine("The program will parse the input file, modify the contents and output the result to " + "the output file"); return(-1); } // Creates a mapping between the quality control strategy and the implementation. This uses // type and not a direct instantiation to prevent to prevent more complicated classes interfering with // each other should this algorithm ultimately be paralleled. var qualityAlgorithmFactory = new QualityAlgorithmFactory(new Dictionary <QualityStrategy, Type>() { { QualityStrategy.Stable, typeof(StableQualityAlgorithm) }, { QualityStrategy.LinearDecrease, typeof(LinearDecreaseAlgorithm) }, { QualityStrategy.LinearIncrease, typeof(LinearIncreaseAlgorithm) }, { QualityStrategy.RapidDecrease, typeof(RapidDecreaseAlgorithm) }, { QualityStrategy.IncreasingUntilSellBy, typeof(IncreasingValueUntilSellByAlgorithm) }, }); // Creates a mapping between the shelf life strategy and the implementation. var shelfLifeAlgorithmFactory = new ShelfLifeAlgorithmFactory(new Dictionary <ShelfLifeStrategy, Type>() { { ShelfLifeStrategy.Stable, typeof(StableShelfLifeAlgorithm) }, { ShelfLifeStrategy.LinearDecrease, typeof(LinearDecreaseShelfLifeAlgorithm) } }); // Creates a mapping between an item of stock and it's corresponding stock management strategy. var itemFactory = new ItemFactory(new Dictionary <string, StockManagementStrategy>() { { "Aged Brie", new StockManagementStrategy(QualityStrategy.LinearIncrease, ShelfLifeStrategy.LinearDecrease) }, { "Backstage passes", new StockManagementStrategy(QualityStrategy.IncreasingUntilSellBy, ShelfLifeStrategy.LinearDecrease) }, { "Sulfuras", new StockManagementStrategy(QualityStrategy.Stable, ShelfLifeStrategy.Stable) }, { "Normal Item", new StockManagementStrategy(QualityStrategy.LinearDecrease, ShelfLifeStrategy.LinearDecrease) }, { "Conjured", new StockManagementStrategy(QualityStrategy.RapidDecrease, ShelfLifeStrategy.LinearDecrease) } }); // Define a list of quality control steps that must be run every time var qualityControl = new List <IQualityAlgorithm>() { new QualityNeverNegativeAlgorithm(), new QualityNeverAboveThresholdAlgorithm(50) }; // And now the object that creates the factory for the item. var qualityFactory = new QualityPipelineFactory(qualityAlgorithmFactory, qualityControl); // Create an object that can parse the text. If multiple formats are required this could be created via // a factory object. For now, we only have one format var stringParse = new SpaceSeparatedParser(); // Create the processing object that performs the main business logic var itemProcessor = new ItemProcessor(qualityFactory, shelfLifeAlgorithmFactory); // Create the object that can convert between our parsed item and the real inventory item var itemToInventoryParse = new ParsedItemToInventoryItemConverter(itemFactory); try { // Open the input file await using var inputStream = new FileStream(args[0], FileMode.Open); // Create the output file await using var outputStream = new FileStream(args[1], FileMode.Create); await using var outputStreamWriter = new StreamWriter(outputStream); // Create the object that performs the final output var outputProcessor = new OutputProcessor(outputStreamWriter); // Run the pipeline by awaiting on the observable await create_observable_stream(inputStream, stringParse, itemToInventoryParse, itemProcessor, outputProcessor); Console.WriteLine("File processed."); // The file was processed successfully. We do not consider any parsing errors as significant (since // the output file has been marked accordingly). return(0); } catch (Exception ex) { Console.WriteLine( $"The process could not be completed because an error occurred. Exception: {ex.Message}"); return(-1); } }
/// <summary> /// 执行接口序列化 /// </summary> /// <param name="responseModel"></param> /// <param name="requestModel"></param> /// <returns></returns> private string GetOutPutContent(ResponseModelType responseModel, RequestModelType requestModel) { //responseModel.respTime = DateTime.Now; return(OutputProcessor.OutPut <ResponseModelType>(responseModel)); }
/// <summary> /// Convenien /// </summary> /// <param name="box"></param> /// <param name="inputs"></param> /// <param name="fun"></param> public void Test(SharpNeat.Phenomes.IBlackBox box, IList<double> inputs, OutputProcessor fun) { var outputs = new double[nbOutputsNN]; activate(box, inputs, outputs); for (int i = 0; i < nbClusters; i++) { for (int j = 0; j < n; j++) { for (int k = 0; k < m; k++) { fun(i, GetOutputValuePerCluster(outputs, j, k)[i]); } } } }
public string GetChart() { if (list == null || list.Count == 0) { return(""); } Dictionary <string, string> summary = new Dictionary <string, string>(); Int64 total = 0; Int64 total_processingTime = 0; Int64 max_processingTime = 0; foreach (Latency.EventRecord_Sec lb in list) { total += lb.Count; total_processingTime += lb.Sum_ProcessingTime; if (max_processingTime < lb.Max_ProcessingTime) { max_processingTime = lb.Max_ProcessingTime; } } summary.Add("Events Processed", total.ToString()); summary.Add("Avg Processing Time", ((total_processingTime) / total) + " microseconds"); summary.Add("Max Processing Time", max_processingTime + " microseconds"); string sumHtml = OutputProcessor.ConvertDictionaryToHTMLTable(summary); Controller.AddChartDataSummary_new(order, chartName, (int)((total_processingTime) / total)); Dictionary <string, List <string> > dict = new Dictionary <string, List <string> >(); /*Date.UTC(1970, 10, 25,10,20,55), 1*/ List <string> Avg_Duration = new List <string>(); foreach (Latency.EventRecord_Sec lb in list) { string str = "Date.UTC(" + lb.EventTimeStamp.Year.ToString() + "," + lb.EventTimeStamp.Month.ToString() + "," + lb.EventTimeStamp.Day.ToString() + "," + lb.EventTimeStamp.Hour.ToString() + "," + lb.EventTimeStamp.Minute.ToString() + "," + lb.EventTimeStamp.Second.ToString() + ")," + lb.Avg_ProcessingTime; Avg_Duration.Add(str); } dict.Add(chartName + "->Avg_ProcessingTime", Avg_Duration); Controller.AddChartData_new(order, chartName, Avg_Duration); Dictionary <string, List <string> > dict2 = new Dictionary <string, List <string> >(); List <string> trans = new List <string>(); foreach (Latency.EventRecord_Sec lb in list) { string str = "Date.UTC(" + lb.EventTimeStamp.Year.ToString() + "," + lb.EventTimeStamp.Month.ToString() + "," + lb.EventTimeStamp.Day.ToString() + "," + lb.EventTimeStamp.Hour.ToString() + "," + lb.EventTimeStamp.Minute.ToString() + "," + lb.EventTimeStamp.Second.ToString() + ")," + lb.Count; trans.Add(str); } dict2.Add(chartName + "->Count/Sec", trans); string chartHtml = Output.HighCharts.GetChartHtml(chartName + "->Avg ProcessingTime/sec", "", "Time", "Duration (Microsecond)", dict, "#005c99"); string chartHtml2 = Output.HighCharts.GetChartHtml(chartName + "->Count/sec", "", "Time", "Count", dict2, "#408000"); return(sumHtml + "<br>" + chartHtml + "<br>" + chartHtml2); }
internal ProcessingUnit() { Output = new OutputProcessor(); Database = new DatabaseProcessor(); }
/// <inheritdoc/> public async Task <ConnectResult> ConnectAsync(IActivityMonitor?m, MqttClientCredentials?credentials = null, OutgoingLastWill?lastWill = null) { if (IsConnected) { throw new InvalidOperationException("This client is already connected."); } using (m?.OpenTrace("Connecting...")) { try { (IOutgoingPacketStore store, IIncomingPacketStore packetIdStore) = await _config.StoreFactory.CreateAsync(m, _pConfig, _config, _config.ConnectionString, credentials?.CleanSession ?? true); IMqttChannel channel = await _config.ChannelFactory.CreateAsync(m, _config.ConnectionString); ConnectAckReflex connectAckReflex = new(); Task <ConnectResult> connectedTask = connectAckReflex.Task; var output = new OutputPump(this, _pConfig); OutputProcessor outputProcessor; var input = new InputPump(this, channel.DuplexPipe.Input, connectAckReflex.ProcessIncomingPacket); OpenPumps(m, new ClientState(input, output, channel, packetIdStore, store)); ReflexMiddlewareBuilder builder = new ReflexMiddlewareBuilder() .UseMiddleware(new PublishReflex(_config, packetIdStore, OnMessage, output)) .UseMiddleware(new PublishLifecycleReflex(packetIdStore, store, output)) .UseMiddleware(new SubackReflex(store)) .UseMiddleware(new UnsubackReflex(store)); if (_config.KeepAliveSeconds == 0) { outputProcessor = new OutputProcessor(output, channel.DuplexPipe.Output, store); } else { OutputProcessorWithKeepAlive withKeepAlive = new(_config, output, channel.DuplexPipe.Output, store);; outputProcessor = withKeepAlive; _ = builder.UseMiddleware(withKeepAlive); } output.StartPumping(outputProcessor); connectAckReflex.Reflex = builder.Build(InvalidPacket); OutgoingConnect outgoingConnect = new(_pConfig, _config, credentials, lastWill); CancellationTokenSource cts = new(_config.WaitTimeoutMilliseconds); IOutgoingPacket.WriteResult writeConnectResult = await outgoingConnect.WriteAsync(_pConfig.ProtocolLevel, channel.DuplexPipe.Output, cts.Token); if (writeConnectResult != IOutgoingPacket.WriteResult.Written) { _ = await CloseAsync(DisconnectedReason.None); return(new ConnectResult(ConnectError.Timeout)); } Task timeout = _config.DelayHandler.Delay(_config.WaitTimeoutMilliseconds, CloseToken); _ = await Task.WhenAny(connectedTask, timeout); // This following code wouldn't be better with a sort of ... switch/pattern matching ? if (connectedTask.Exception is not null) { m?.Fatal(connectedTask.Exception); _ = await CloseAsync(DisconnectedReason.None); return(new ConnectResult(ConnectError.InternalException)); } if (CloseToken.IsCancellationRequested) { _ = await CloseAsync(DisconnectedReason.None); return(new ConnectResult(ConnectError.RemoteDisconnected)); } if (!connectedTask.IsCompleted) { _ = await CloseAsync(DisconnectedReason.None); return(new ConnectResult(ConnectError.Timeout)); } ConnectResult res = await connectedTask; if (res.ConnectError != ConnectError.Ok) { _ = await CloseAsync(DisconnectedReason.None); return(new ConnectResult(res.ConnectError)); } bool askedCleanSession = credentials?.CleanSession ?? true; if (askedCleanSession && res.SessionState != SessionState.CleanSession) { _ = await CloseAsync(DisconnectedReason.None); return(new ConnectResult(ConnectError.ProtocolError_SessionNotFlushed)); } if (res.SessionState == SessionState.CleanSession) { ValueTask task = packetIdStore.ResetAsync(); await store.ResetAsync(); await task; } else { throw new NotImplementedException(); } return(res); } catch (Exception e) { m?.Error("Error while connecting, closing client.", e); _ = await CloseAsync(DisconnectedReason.None); return(new ConnectResult(ConnectError.InternalException)); } } }
public SubFunctions(OutputProcessor output) { this.output = output; // 대소문자 미구분자 comp = StringComparison.OrdinalIgnoreCase; }
public void Test(SharpNeat.Phenomes.IBlackBox box, IList<double> inputs, OutputProcessor fun) { var actualOutputs = new double[nbClusters]; activate(box, inputs, actualOutputs); for (int i = 0; i < nbClusters; i++) { fun(i, actualOutputs[i]); } }
/// <summary> /// 执行接口序列化 /// </summary> /// <param name="responseModel"></param> /// <param name="requestModel"></param> /// <returns></returns> private string GetOutPutContent(ResponseModelType responseModel, RequestModelType requestModel) { return(OutputProcessor.OutPut <ResponseModelType>(responseModel, IgnoreList)); }
public void Test(SharpNeat.Phenomes.IBlackBox box, IList<double> inputs, OutputProcessor fun) { var actualOutputs = new double[dataset.OutputCount]; activate(box, inputs, actualOutputs); for (int i = 0; i < dataset.OutputCount; i++) { fun(i, actualOutputs[i]); } }