public void MoveNext(RegisterCommands command) { MyRegistrationState previewState = CurrentState; CurrentState = GetNext(command); if (this.MyRegistrationListener != null && previewState != CurrentState) { MyRegistrationListener.onMyRegistrationStateChanged(CurrentState); } }
public MyRegistrationState GetNext(RegisterCommands command) { StateTransition transition = new StateTransition(CurrentState, command); MyRegistrationState nextState; if (!transitions.TryGetValue(transition, out nextState)) { throw new Exception("Invalid transition: " + CurrentState + " -> " + command); } return(nextState); }
public static Dictionary <string, CommandProcessor> GetCommandProcessors() { return(NoAddressCommandsFactory.GetCommands() .Concat(CycleCommandsFactory.GetCommands()) .Concat(JumpCommandsFactory.GetCommands()) .Concat(RamCommands.GetCommands()) .Concat(BitRamCommands.GetCommands()) .Concat(BitRegisterCommands.GetCommands()) .Concat(InOutCommands.GetCommands()) .Concat(RegisterCommands.GetCommands()) .Concat(RamRegisterCommands.GetCommands()) .ToDictionary(x => x.Key, x => x.Value)); }
protected override bool OnPerform() { if (RegisterCommands.Perform()) { // Stop the task return(false); } else { // Continue the task return(true); } }
public void register(RegisterCommands command) { registrationService.setRegistrationListener(this); CancellationTokenSource ts = new CancellationTokenSource(); try { new Task(() => { resetLoginProccesss(false); registrationProcess.MoveNext(command); }).Start(); //throw new TimeoutException(); } catch (AggregateException aggregateException) { // resetLoginProccesss(true, LoginError.TimeOut); throw aggregateException.InnerException; } }
public StateTransition(MyRegistrationState currentState, RegisterCommands command) { CurrentState = currentState; Command = command; }
private void doLogin(RegisterCommands command) { stack_registrar.IsVisible = false; load.IsVisible = true; loginService.register(command); }
public async Task <IActionResult> Register([FromBody] RegisterCommands command) { var response = await _mediator.Send(command).ConfigureAwait(false); return(Ok(response)); }
public static void Main(string[] args) { PlatformServices ps = PlatformServices.Default; IApplicationEnvironment env = ps.Application; IConfigurationBuilder builder = new ConfigurationBuilder() .AddEnvironmentVariables() .SetBasePath(env.ApplicationBasePath); IHostingEnvironment hostingEnv = new HostingEnvironment(); hostingEnv.Initialize(env.ApplicationBasePath, builder.Build()); if (hostingEnv.IsDevelopment()) { Console.WriteLine("Loading from UserSecret store"); builder.AddUserSecrets(); } else { Console.WriteLine("Loading from jsons directory"); builder.AddJsonFile(@"..\..\..\..\..\..\MechHisui-jsons\secrets.json"); } IConfiguration config = builder.Build(); var client = new DiscordClient(conf => { conf.AppName = "MechHisui"; conf.AppVersion = "0.3.0"; conf.LogLevel = LogSeverity.Info; //conf.UseLargeThreshold = true; }); //client.Disconnected += (s, e) => Environment.Exit(0); Console.CancelKeyPress += async(s, e) => await RegisterCommands.Disconnect(client, config); //Display all log messages in the console client.Log.Message += (s, e) => Console.WriteLine($"{DateTime.Now} - [{e.Severity}] {e.Source}: {e.Message} {e.Exception}"); //Add a ModuleService and CommandService client.AddService(new ModuleService()); client.UsingCommands(conf => { conf.AllowMentionPrefix = true; conf.HelpMode = HelpMode.Public; conf.PrefixChar = '.'; }); //register commands client.RegisterAddChannelCommand(config); client.RegisterDeleteCommand(config); client.RegisterDisconnectCommand(config); if (!Debugger.IsAttached) { client.RegisterEvalCommand(config); } //client.RegisterImageCommand(config); client.RegisterInfoCommand(config); client.RegisterKnownChannelsCommand(config); client.RegisterLearnCommand(config); client.RegisterPickCommand(config); //client.RegisterRecordingCommand(config); client.RegisterResetCommand(config); client.RegisterRollCommand(config); client.RegisterThemeCommand(config); client.RegisterWhereCommand(config); client.RegisterXmasCommand(config); client.RegisterAPCommand(config); client.RegisterDailyCommand(config); client.RegisterEventCommand(config); client.RegisterFriendsCommand(config); client.RegisterLoginBonusCommand(config); client.RegisterStatsCommands(config); client.RegisterQuartzCommand(config); client.RegisterZoukenCommand(config); client.RegisterHisuiBetsCommands(config); client.RegisterSecretHitler(config); client.RegisterTriviaCommand(config); Responses.InitResponses(config); int lastcode = 0; if (args.Length > 0 && Int32.TryParse(args[0], out lastcode) && lastcode != 0) { Console.WriteLine($"Last exit code was {lastcode}"); } client.MessageUpdated += async(s, e) => { if (!(await e.Channel.DownloadMessages(10, e.Before.Id, Relative.After)).Any(m => m.IsAuthor)) { var msgReceived = typeof(DiscordClient).GetMethod("OnMessageReceived", BindingFlags.NonPublic | BindingFlags.Instance); msgReceived.Invoke(s, new object[] { e.After }); //client.OnMessageReceived(e.After); } }; try { //Convert our sync method to an async one and block the Main function until the bot disconnects client.ExecuteAndWait(async() => { //Connect to the Discord server using our email and password await client.Connect(config["Email"], config["Password"]); Console.WriteLine($"Logged in as {client.CurrentUser.Name}"); Console.WriteLine($"MH v. 0.3.0"); //Use a channel whitelist client.GetService <ModuleService>().Add( new ChannelWhitelistModule( Helpers.ConvertStringArrayToULongArray( //config["API_testing"] //config["LTT_general"], //config["LTT_testing"], config["FGO_playground"], config["FGO_Hgames"], config["FGO_events"], config["FGO_general"] ) ), nameof(ChannelWhitelistModule), ModuleFilter.ChannelWhitelist ); if (!client.Servers.Any()) { Console.WriteLine("Not a member of any server"); } else { foreach (var prChannel in client.PrivateChannels) { if (prChannel.Id == UInt64.Parse(config["PrivChat"])) { client.MessageReceived += (new Responder(prChannel, client).Respond); } } foreach (var channel in Helpers.IterateChannels(client.Servers, printServerNames: true, printChannelNames: true)) { if (!channel.IsPrivate && Helpers.IsWhilested(channel, client)) { //Console.CancelKeyPress += async (s, e) => await client.SendMessage(channel, config["Goodbye"]); client.MessageReceived += (new Responder(channel, client).Respond); if (channel.Id != UInt64.Parse(config["API_testing"])) { if (Debugger.IsAttached) { // await channel.SendMessage("MechHisui started in debug mode. Not all commands will be available."); } else if (lastcode != -1 && channel.Id != UInt64.Parse(config["FGO_events"])) { await channel.SendMessage(config["Hello"]); } } } } if (!Debugger.IsAttached) { client.AddNewHisuiBetsUsers(config); } Console.WriteLine($"Started up at {DateTime.Now}."); } }); } catch (Exception ex) { File.AppendAllText(Path.Combine(config["Logs"], "crashlogs.txt"), $"{DateTime.Now} - {ex.Message}\n{ex.StackTrace}\n"); Environment.Exit(-1); } }
private void DeleteTTLValue() { Notification = RegisterCommands.DeleteTTLKey(); CurrentTTL = RegisterCommands.ReadRegistryKey(); }
private void SetTTLValue() { RegisterCommands.CreateTTLKey(NewTTL); CurrentTTL = RegisterCommands.ReadRegistryKey(); }
public TTLViewModel() { CurrentTTL = RegisterCommands.ReadRegistryKey(); }