예제 #1
0
        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();
        }
예제 #2
0
파일: Host.cs 프로젝트: Ivony/HelloWorld
        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;
        }
예제 #3
0
        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();
        }