public static void Initialize( GameRulesBase rules, IGameDataService dataService, IGameMessageService messageService ) { if ( rules == null ) throw new ArgumentNullException( "rules" ); if ( dataService == null ) throw new ArgumentNullException( "dataService" ); if ( messageService == null ) throw new ArgumentNullException( "messageService" ); GameRules = rules; DataService = dataService; MessageService = messageService; rules.Initialize(); DataService.Initialize(); }
public static void Initailze(HttpConfiguration configuration) { var configPath = ConfigurationManager.AppSettings["DataPath"] ?? "Data"; var dataRoot = Path.Combine(HostingEnvironment.ApplicationPhysicalPath, configPath); UserService = new JsonUserService(dataRoot); DataService = new JsonDataService(dataRoot); MessageService = new TextFileMessageService(dataRoot); var typeResolver = new HttpRuntimeTypeResolver(configuration.Services.GetAssembliesResolver()); var rules = StarveGameRules.CreateInstance(typeResolver); GameHost.Initialize(rules, DataService, MessageService); configuration.Services.Replace(typeof(IContentNegotiator), new JsonContentNegotiator()); configuration.Formatters.JsonFormatter.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc; }
public static void Initialize(GameRulesBase rules, IGameDataService dataService, IGameMessageService messageService) { if (rules == null) { throw new ArgumentNullException("rules"); } if (dataService == null) { throw new ArgumentNullException("dataService"); } if (messageService == null) { throw new ArgumentNullException("messageService"); } GameRules = rules; DataService = dataService; MessageService = messageService; rules.Initialize(); DataService.Initialize(); }