public ElectroController(IEnumerable<Election> elections, IEnumerable<KeyValuePair<Guid, PrivateKey>> keys, AuthController authController, StatePersister statePersister) { this.authController = authController; this.statePersister = statePersister; LoadState(elections, keys); }
static void Main(string[] args) { XmlConfigurator.Configure(); try { ThreadPool.SetMinThreads(32, 1024); var statePersister = new StatePersister(); AuthController authController = new AuthController(StatePersister.LoadUsers(), statePersister); ElectroController electroController = new ElectroController(StatePersister.LoadElections(), StatePersister.LoadKeys(), authController, statePersister); var staticHandler = new StaticHandler(GetPrefix(null), Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "web")); staticHandler.Start(); var registerHandler = new RegisterHandler(authController, GetPrefix("register")); registerHandler.Start(); var loginHandler = new LoginHandler(authController, GetPrefix("login")); loginHandler.Start(); var logoutHandler = new LogoutHandler(authController, GetPrefix("logout")); logoutHandler.Start(); var startElectionHandler = new StartElectionHandler(electroController, authController, GetPrefix("startElection")); startElectionHandler.Start(); var listElectionsHandler = new ListElectionsHandler(electroController, authController, GetPrefix("listElections")); listElectionsHandler.Start(); var findElectionHandler = new FindElectionHandler(electroController, authController, GetPrefix("findElection")); findElectionHandler.Start(); var nominateHandler = new NominateHandler(electroController, authController, GetPrefix("nominate")); nominateHandler.Start(); var voteHandler = new VoteHandler(electroController, authController, GetPrefix("vote")); voteHandler.Start(); while(true) { Thread.Sleep(electionsSnapshotTimeoutMs); try { log.Info("Saving elections snapshot"); StatePersister.SaveAllElections(electroController.DumpElections().Reverse()); log.Info("Elections snapshot saved"); } catch(Exception e) { log.Error("Failed to save elections snapshot. Sleeping and retrying", e); } } } catch(Exception e) { log.Fatal(e); } }
public AuthController(IEnumerable<User> users, StatePersister statePersister) { LoadState(users); this.statePersister = statePersister; }
public AuthController(IEnumerable <User> users, StatePersister statePersister) { LoadState(users); this.statePersister = statePersister; }
public ElectroController(IEnumerable <Election> elections, IEnumerable <KeyValuePair <Guid, PrivateKey> > keys, AuthController authController, StatePersister statePersister) { this.authController = authController; this.statePersister = statePersister; LoadState(elections, keys); }