/// <summary> /// State is intialised on applicaton start. /// Usually I would use Autofac for this - but it wasn't compatible with WCF without the SVC file. /// I opted to not use an SVC file because I like to be able to explicitly state my routes to ensure they are REST /// </summary> public static SiteState Initialise(IConfiguration config, IRepository <User, UserPet> users, IRepository <Pet, PetMetric> pets, IRepository <Animal, AnimalMetric> animals, IRepository <Interaction, MetricInteraction> interactions, IRepository <Metric, MetricInteraction> metrics, IDataProvider <User> userDataProvider, ISiteRequestProcessor requestProcessor, IContainer userSessionContainer) { if (IsInitalised) { throw new Exception("The site state is already initialised"); } //Builder var responseBuilder = ResponseBuilder.Initialise(animals, metrics, pets, interactions); //GameData var gameState = GameDataState.Initialize(config, animals, metrics, interactions, responseBuilder); //Validators var registrationValidator = new RegistrationValidator(users); var userSessionRequestValidator = new NewUserSessionValidator(users, new Encrypter(config)); var siteValidator = new SiteRequestRequestValidator(registrationValidator, userSessionRequestValidator); IsInitalised = true; return(new SiteState(gameState, users, pets, animals, interactions, requestProcessor, siteValidator, config, responseBuilder, userSessionContainer)); }
private SiteState(GameDataState gameState, IRepository <User, UserPet> users, IRepository <Pet, PetMetric> pets, IRepository <Animal, AnimalMetric> animals, IRepository <Interaction, MetricInteraction> interactions, ISiteRequestProcessor processor, ISiteRequestValidator siteRequestValidator, IConfiguration config, ResponseBuilder responseBuilder, IContainer userSessionContainer) { _gameState = gameState; _currentUserSessions = new List <UserSessionState>(); _users = users; _pets = pets; _animals = animals; _interactions = interactions; ResponseBuilder = responseBuilder; _processor = processor; _siteRequestValidator = siteRequestValidator; _config = config; _userSessionContainer = userSessionContainer; }