Пример #1
0
        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;
        }
Пример #2
0
        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;
        }