void IConsoleHandler.OnAwake(ConsoleData a_data) { _inputField.characterLimit = a_data.MaxConsoleInput; _rawInput = new StringBuilder(a_data.MaxConsoleInput); _currentString = new StringBuilder(a_data.MaxConsoleInput); _updateContextLogic = new UpdateContextLogic(_raycastLayers); _updateContextLogic.OnContextSet += OnContextSet; CreatePredictionObject(); AwakeHistoryItemPool(); _inputField.onValidateInput += OnValidateInput; Transform parent = _inputField.transform.parent; if (parent) { Transform caretTransform = parent.GetChild(0); if (caretTransform) { caretTransform.SetAsLastSibling(); } } SelectPredictionItem(_selectedPredictionItem); }
private static void APIConnection_OutputData(object sender, OutputEventArgs e) { if (e.Data == null) { return; } if (e.Data.IndexOf(chatTag) == 0) { ChatData?.Invoke(sender, new OutputEventArgs(e.Data.Substring(chatTag.Length))); } else if (e.Data.IndexOf(srvDataTagPlayer) == 0) { String result = e.Data.Substring(srvDataTagPlayer.Length); PlayerActivityEnum act = PlayerActivityEnum.Join; if (Regex.Match(result, "[A-Za-z0-9\\-]+" + srvPlayerJoin).Success) { act = PlayerActivityEnum.Join; result = result.Remove(result.Length - srvPlayerJoin.Length, srvPlayerJoin.Length); } if (Regex.Match(result, "[A-Za-z0-9\\-]+" + srvPlayerLeave).Success) { act = PlayerActivityEnum.Leave; result = result.Remove(result.Length - srvPlayerLeave.Length, srvPlayerLeave.Length); } PlayerData?.Invoke(sender, new PlayerEventArgs(result, act)); } ConsoleData?.Invoke(sender, e); }
public void WriteDataToItself() { var expectedString = "Test Data"; var data = new ConsoleData(expectedString); data.Read().ShouldBe(expectedString); }
protected override bool CheckMyParametersAndConfig(ConsoleParameter p, ConsoleData d) { foreach (var s in MyConfig.GetConfigurationList("Mail")) { p[DomainKey.CONFIG, $"Mail_{s.Key}"] = s.Value; } return(true); }
public void ReturnLastDataQueued() { var console = new SystemConsole(); var data = new ConsoleData("Test Data"); console.BufferData(data); console.GetLastBuffered().ShouldBe(data); }
public ConsoleImpl(IConsoleHandler a_handler, ConsoleData a_data) { CommandLookup = new ConsoleCommandLookup(a_data.MaxCommands); s_Handler = a_handler; s_ConsoleHistory = new KQueue <LogData>(a_data.MaxHistory); s_CommandHistory = new KQueue <ICommand>(a_data.MaxHistory); s_MaxHistory = a_data.MaxHistory; }
public static GameTargetPlatform Init() { pc = new PCData(); mobile = new MobileData(); console = new ConsoleData(); web = new WebData(); return(GetCurrent()); }
public void HaveAnEmptyQueueWhenFlushed() { var console = new SystemConsole(); var data = new ConsoleData("Test Data"); console.BufferData(data); console.Flush(); console.GetBuffered().ShouldBeEmpty(); }
public void EmptyBufferOnReset() { var console = new SystemConsole(); var data = new ConsoleData("Test Data"); console.BufferData(data); console.ResetBuffer(); console.GetBuffered().ShouldBeEmpty(); }
public static void Initialize(ConsoleData data) { Console.data = data; consoleBase = new ConsoleCore(WriteLine) { }; Console.WriteLine(data.StartMessage); }
public void AllowDataToBeOverwritten() { var initialData = "Test Data"; var data = new ConsoleData(initialData); var overwriteData = "Overwrite Data"; data.Write(overwriteData); data.Read().ShouldNotBe(initialData); data.Read().ShouldBe(overwriteData); }
/// <summary> /// Initialises the Console Handler /// </summary> public void OnAwake(ConsoleData a_data) { s_Handler.OnAwake(a_data); if (s_Handler.IsOpen) // Ensure Console is Closed { s_Handler.Close(); } // Apply Visual Scheme s_Handler.OnVisualChange(); }
void OnDisable() { if (s_Console == null && s_ConsoleData == null) { return; } ClearViews(); s_ConsoleData.OnLogUpdated = null; s_Console = null; s_ConsoleData = null; Application.logMessageReceived -= HandleUnityLog; }
void OnEnable() { if (s_ConsoleData == null) { s_ConsoleData = new ConsoleData(); s_ConsoleData.AutoRegisterConsoleCommands(); } s_ConsoleData.OnLogUpdated = UpdateLog; s_Console = this; Application.logMessageReceived += HandleUnityLog; Log("Console initialized successfully"); }
/// <summary> /// Run all project. /// </summary> static void Main(string[] args) { Stopwatch sw_total = new Stopwatch(); sw_total.Start(); List <IRunable> tasks = new List <IRunable>(); IWriteReadable output = null; Console.WriteLine("Input 1 - output data in console, 2 - output data in file"); int checker = Convert.ToInt32(Console.ReadLine()); if (checker == 1) { output = new ConsoleData(); } else if (checker == 2) { output = new FileData(); } else { Environment.Exit(0); } ILogging logger = new FileLogger(); tasks.Add(new MainClassOfStruct(output, logger)); tasks.Add(new MainClassOfEnum(output, logger)); tasks.Add(new MainClassOfIOStream(output, logger)); tasks.Add(new MainClassOfException(output, logger)); tasks.Add(new MainClassOfSerializations(output, logger)); tasks.Add(new MainClassOfReflection(output)); tasks.Add(new MainClassOfStyleCop(output)); tasks.Add(new MainClassOfThreading(output)); tasks.Add(new MainClassOfIoCContainer(output, logger)); tasks.Add(new MainClassOfExcel(output, logger)); tasks.Add(new MainClassOfDirectories(output, logger)); foreach (var task in tasks) { task.Run(); } sw_total.Stop(); output.Write("Execute time: " + sw_total.ElapsedMilliseconds + " ms"); Console.ReadKey(); }
void OnEnable() { s_ConsoleData = new ConsoleData(); s_ConsoleData.AutoRegisterConsoleCommands(); s_ConsoleData.OnLogUpdated = UpdateLog; s_Console = this; Application.logMessageReceived += HandleUnityLog; LogText.font.RequestCharactersInTexture("qwertyuiopasdfghjklzxcvbnmQWERYTUIOPASDFGHJKLZXCVBNM1234567890~`!@#$%^&*()_+{}[]:;\"'/.,?><"); Log("Console initialized successfully"); UpdateLog(); }
protected override void DoProcess(ConsoleParameter p, ConsoleData d) { try { base.DoProcess(p, d); } catch (Exception ex) { OnTaskError(ex); throw ex; } finally { AfterExcute(); } }
static void Main() { string answer; do { Console.WriteLine("Uravninie tipa y=kx+b"); Console.WriteLine("Vvedite kooficenti k,b po ocheridi"); var first = new Line(ConsoleData.GetData(), ConsoleData.GetData()); Console.WriteLine("Vvedite kooficenti k,b po ocheridi"); var second = new Line(ConsoleData.GetData(), ConsoleData.GetData()); var c = Operations.Cross(first, second); point.print(c); Console.WriteLine("Zadat` parametri zanavo? (Y/N)"); answer = Console.ReadLine(); }while ((answer == "y") || (answer == "Y")); }
static void Main() { string answer; do { Console.WriteLine("Уравнение прямой типа y=kx+b"); Console.WriteLine("Введите коофиценты k,b по очереди"); var first = new Line(ConsoleData.GetData(), ConsoleData.GetData()); Console.WriteLine("Введите коофиценты k,b по очереди"); var second = new Line(ConsoleData.GetData(), ConsoleData.GetData()); var c = Operations.Cross(first, second); point.print(c); Console.WriteLine("Задать параметры заново? (Y/N)"); answer = Console.ReadLine(); }while ((answer == "y") || (answer == "Y")); }
public static void ProcessData(string result) { BaseData resultData; switch (result) { case "Database": // on db resultData = new DatabaseData(result); break; case "File": // file resultData = new FileData(result); break; default: // on Screen resultData = new ConsoleData(result); break; } resultData.Process(); }
protected override void InvokeBusiness(ConsoleParameter p, ConsoleData d) { if (p.ExtentionObj.stop != null && p.ExtentionObj.stop) { isrun = false; GlobalCommon.Logger.WriteLog(Base.Constants.LoggerLevel.INFO, $"接收到stop指令,准备结束运行,请等待..."); } if (_excute_options.IsNotExcute) { GlobalCommon.Logger.WriteLog(Base.Constants.LoggerLevel.INFO, $"程式不执行"); } else if (_excute_options.IsImmediately) { //立即执行并且只执行一次 //如果没指定要调用的逻辑,则默认都执行一次 foreach (var k in _call_dic.Keys) { var isrepeat = false; var repeatcount = 0; var repeattimes = 0; do { if (isrepeat) { repeatcount++; GlobalCommon.Logger.WriteLog(Base.Constants.LoggerLevel.INFO, $"当前为任务{k}第{repeatcount}次重复执行"); } try { using (var cp = p.DeepCopy <ConsoleParameter>()) { using (var cd = d.DeepCopy <ConsoleData>()) { GlobalCommon.Logger.WriteLog(Base.Constants.LoggerLevel.INFO, $"开始执行任务{k}"); var lname = k.Split('.')[0]; var action = k.Split('.')[1]; cp.CallLogicName = lname; cp.CallAction = action; if (!string.IsNullOrEmpty(cp.CallLogicName) && !string.IsNullOrEmpty(cp.CallAction)) { var logic = _call_dic[k].NewInstance(); logic.process(cp, cd); GlobalCommon.Logger.WriteLog(Base.Constants.LoggerLevel.INFO, $"结束任务{k}"); } else { GlobalCommon.Logger.WriteLog(Base.Constants.LoggerLevel.INFO, $"任务{k}不符合任务执行选项标准,故不执行"); } } } isrepeat = false; repeatcount = 0; repeattimes = 0; } catch (Exception ex) { var errormsg = new StringBuilder(); errormsg.AppendLine(); errormsg.AppendLine($"任务{k}执行出错,错误信息为{ex.Message}"); errormsg.AppendLine(ex.StackTrace); if (ex.InnerException != null) { errormsg.AppendLine(ex.InnerException.Message); errormsg.AppendLine(ex.StackTrace); } GlobalCommon.Logger.WriteLog(Base.Constants.LoggerLevel.ERROR, errormsg.ToString()); if (_call_dic[k].RepeatWhenExceptionType != null && (ex.GetType().FullName == _call_dic[k].RepeatWhenExceptionType.FullName || ex.GetType().IsSubclassOf(_call_dic[k].RepeatWhenExceptionType) || (ex.InnerException != null && (ex.InnerException.GetType().FullName == _call_dic[k].RepeatWhenExceptionType.FullName || ex.InnerException.GetType().IsSubclassOf(_call_dic[k].RepeatWhenExceptionType))))) { if (!isrepeat) { isrepeat = true; repeattimes = _call_dic[k].RepeatTimes; GlobalCommon.Logger.WriteLog(Base.Constants.LoggerLevel.INFO, $"任务{k}执行出现异常,因设定重复执行任务,因此进入重复执行序列,直到执行完成或达到重复次数,设定的重复次数为{repeattimes}"); } } else { isrepeat = false; repeatcount = 0; repeattimes = 0; } } finally { GC.Collect(); } } while (isrepeat && repeatcount < repeattimes); } } else { while (isrun) { var dt = DateTime.Now; var rs = _next_run_schedule.Where(t => 1 == 1).ToDictionary(k => k.Key, v => v.Value); foreach (var item in rs) { if (dt >= item.Value) { if (!IsRun(item.Key)) { SetRunFlag(item.Key); var task = Task.Run(() => { //等待task添加到dictionary中 Task.Delay(100).Wait(); var isrepeat = false; var repeatcount = 0; var repeattimes = 0; do { if (isrepeat) { repeatcount++; GlobalCommon.Logger.WriteLog(Base.Constants.LoggerLevel.INFO, $"当前为任务{item.Key}第{repeatcount}次重复执行"); } try { using (var cp = p.DeepCopy <ConsoleParameter>()) { using (var cd = d.DeepCopy <ConsoleData>()) { GlobalCommon.Logger.WriteLog(Base.Constants.LoggerLevel.INFO, $"开始执行任务{item.Key}"); var lname = item.Key.Split('.')[0]; var action = item.Key.Split('.')[1]; cp.CallLogicName = lname; cp.CallAction = action; if (!string.IsNullOrEmpty(cp.CallLogicName) && !string.IsNullOrEmpty(cp.CallAction)) { var logic = _call_dic[item.Key].NewInstance(); //提前写入下次执行的时间,便于logic执行善后处理 UpdateNextRunTime(item.Key, dt); cp.ExtentionObj.Next_Excute_Time = _next_run_schedule[item.Key]; cp.ExtentionObj.ExcuteName = _call_dic[item.Key].Name; cp.ExtentionObj.ExcuteDescription = _call_dic[item.Key].Desc; logic.process(cp, cd); GlobalCommon.Logger.WriteLog(Base.Constants.LoggerLevel.INFO, $"结束任务{item.Key},下次执行时间点为{_next_run_schedule[item.Key].ToString("yyyy-MM-dd HH:mm:ss")}"); } else { GlobalCommon.Logger.WriteLog(Base.Constants.LoggerLevel.INFO, $"任务{item.Key}不符合任务执行选项标准,故不执行,后续也不再执行"); } } } isrepeat = false; repeatcount = 0; repeattimes = 0; } catch (Exception ex) { var errormsg = new StringBuilder(); errormsg.AppendLine(); errormsg.AppendLine($"任务{item.Key}执行出错,错误信息为{ex.Message}"); errormsg.AppendLine(ex.StackTrace); if (ex.InnerException != null) { errormsg.AppendLine(ex.InnerException.Message); errormsg.AppendLine(ex.StackTrace); } GlobalCommon.Logger.WriteLog(Base.Constants.LoggerLevel.ERROR, errormsg.ToString()); if (_call_dic[item.Key].RepeatWhenExceptionType != null && (ex.GetType().FullName == _call_dic[item.Key].RepeatWhenExceptionType.FullName || ex.GetType().IsSubclassOf(_call_dic[item.Key].RepeatWhenExceptionType) || (ex.InnerException != null && (ex.InnerException.GetType().FullName == _call_dic[item.Key].RepeatWhenExceptionType.FullName || ex.InnerException.GetType().IsSubclassOf(_call_dic[item.Key].RepeatWhenExceptionType))))) { if (!isrepeat) { isrepeat = true; repeattimes = _call_dic[item.Key].RepeatTimes; GlobalCommon.Logger.WriteLog(Base.Constants.LoggerLevel.INFO, $"任务{item.Key}执行出现异常,因设定重复执行任务,因此进入重复执行序列,直到执行完成或达到重复次数,设定的重复次数为{repeattimes}"); } } else { isrepeat = false; repeatcount = 0; repeattimes = 0; } UpdateNextRunTime(item.Key, dt); } finally { SetStopFlag(item.Key); GC.Collect(); } } while (isrepeat && repeatcount < repeattimes); }); if (_running_task.ContainsKey(item.Key)) { _running_task[item.Key].Wait(); _running_task.Remove(item.Key); _running_task.Add(item.Key, task); } else { _running_task.Add(item.Key, task); } } } //else //{ // GlobalCommon.Logger.WriteLog(Base.Constants.LoggerLevel.INFO, $"任务{item.Key}未到执行时间点,无须执行"); //} } Task.Delay(1000).Wait(); } //结束之前需要等待所有的正在运行的线程执行完成 Task.WaitAll(_running_task.Values.ToArray()); GlobalCommon.Logger.WriteLog(Base.Constants.LoggerLevel.INFO, $"所有任务执行完成,结束运行"); } }
public void NotThrowWhenReadingEmptyData() { var data = new ConsoleData(null); Should.NotThrow(data.Read); }
protected override void AfterProcess(ConsoleParameter p, ConsoleData d) { p.Resources.CommitTransaction(p.CurrentTransToken); }
public Task OnConsole(ConsoleData data) { ensureConsoleNum(data.index); consoleList_[data.index].SetTextLines(data.text); return(Task.FromResult(0)); }