示例#1
0
        public DefaultModel(ModelFactoryResolver modelFactoryResolver)
        {
            this.modelFactoryResolver = modelFactoryResolver;

            this.userCollection = this.modelFactoryResolver.GetFactory <IUpdatableUserCollection>().Create();
            this.BuildData();
        }
示例#2
0
        private ServiceTypeProvider()
        {
            var modelFactories = new IModelFactory[]
            {
                new SessionTimeFactory(),
                new MageKnightFactory(),
                new UserFactory(),
                new UserCollectionFactory(),
                new GameFactory(),
                new GamesFactory(),
                new DialFactory(),
                new StatFactory(),
                new ClickFactory(),
            };

            this.modelFactoryResolver = new ModelFactoryResolver(modelFactories);
            this.defaultModel         = new DefaultModel.DefaultModel(this.modelFactoryResolver);

            IEnumerable <IQueryFactory> queryFactories;

            queryFactories = new IQueryFactory[]
            {
                new SessionTimeQueryFactory(this.modelFactoryResolver, this.defaultModel),
                new MageKnightQueryFactory(this.modelFactoryResolver, this.defaultModel),
                new UserQueryFactory(this.modelFactoryResolver, this.defaultModel),
                new UserCollectionQueryFactory(this.modelFactoryResolver, this.defaultModel),
                new GameQueryFactory(this.modelFactoryResolver, this.defaultModel),
                new GamesQueryFactory(this.modelFactoryResolver, this.defaultModel),
                new DialQueryFactory(this.modelFactoryResolver, this.defaultModel),
                new ClickQueryFactory(this.modelFactoryResolver, this.defaultModel),
                new StatQueryFactory(this.modelFactoryResolver, this.defaultModel),
            };

            this.queryFactoryResolver = new QueryFactoryResolver(queryFactories);

            var modelUpdaters = new IModelUpdater[]
            {
                new SessionTimeChangedUpdater(this.modelFactoryResolver, this.defaultModel),
                new MageKnightChangedUpdater(this.modelFactoryResolver, this.defaultModel),
                new UserChangedUpdater(this.modelFactoryResolver, this.defaultModel),
                new UserCollectionAddedUpdater(this.modelFactoryResolver, this.defaultModel),
                new UserInventoryAddUpdater(this.modelFactoryResolver, this.defaultModel),
                new UserArmyAddUpdater(this.modelFactoryResolver, this.defaultModel),
                new UserAddedMageToArmyUpdater(this.modelFactoryResolver, this.defaultModel),
                new GameChangedModelUpdater(this.modelFactoryResolver, this.defaultModel),
                new GamesChangedModelUpdater(this.modelFactoryResolver, this.defaultModel),
                new UserSignUpUpdater(this.modelFactoryResolver, this.defaultModel),
                new UserBoosterPackCountChangedUpdater(this.modelFactoryResolver, this.defaultModel),
                new UserSignInUpdater(this.modelFactoryResolver, this.defaultModel),
                new UserIsSignedInChangedUpdater(this.modelFactoryResolver, this.defaultModel),
                new GameJoinedUpdater(this.modelFactoryResolver, this.defaultModel),
                new MageKnightCoordinatesChangedUpdater(this.modelFactoryResolver, this.defaultModel),
                new UserSelectedMageChangedUpdater(this.modelFactoryResolver, this.defaultModel),
                new UserAddedMageToInventoryUpdater(this.modelFactoryResolver, this.defaultModel),
            };

            this.modelUpdaterResolver = new ModelUpdaterResolver(modelUpdaters);

            var serverMessageHandlers = new IServerMessageHandler[]
            {
                new SessionTimeChangedHandler(this.modelUpdaterResolver),
                new MageKnightChangedHandler(this.modelUpdaterResolver),
                new UserChangedHandler(this.modelUpdaterResolver),
                new UserCollectionAddedHandler(this.modelUpdaterResolver),
                new UserInventoryAddHandler(this.modelUpdaterResolver),
                new UserAddedMageToArmyHandler(this.modelUpdaterResolver),
                new UserArmyAddHandler(this.modelUpdaterResolver),
                new GameChangedHandler(this.modelUpdaterResolver),
                new GamesChangedHandler(this.modelUpdaterResolver),
                new UserSignUpHandler(this.modelUpdaterResolver),
                new UserBoosterPackCountChangedHandler(this.modelUpdaterResolver),
                new UserSignInHandler(this.modelUpdaterResolver),
                new UserIsSignedInChangedHandler(this.modelUpdaterResolver),
                new GameJoinedHandler(this.modelUpdaterResolver),
                new MageKnightCoordinatesChangedHandler(this.modelUpdaterResolver),
                new UserSelectedMageChangedHandler(this.modelUpdaterResolver),
                new UserAddedMageToInventoryHandler(this.modelUpdaterResolver),
            };

            var serverMessageHandlerResolver = new ServerMessageHandlerResolver(serverMessageHandlers);

            this.QueryHandlerCollectionFactory = new QueryHandlerCollectionFactory(
                this.queryFactoryResolver,
                serverMessageHandlerResolver);

            this.serviceClient = new Lazy <IServiceClient>(
                this.CreateServiceClient,
                LazyThreadSafetyMode.ExecutionAndPublication);

            this.sessionTimeProxyFactory = new Lazy <ISessionTimeProxyFactory>(
                this.CreateSessionTimeProxyFactory,
                LazyThreadSafetyMode.ExecutionAndPublication);

            this.sessionTime = new Lazy <ISessionTime>(
                this.CreateSessionTime,
                LazyThreadSafetyMode.ExecutionAndPublication);

            this.mageKnightProxyFactory = new Lazy <IMageKnightModelProxyFactory>(
                this.CreateMageKnightProxyFactory,
                LazyThreadSafetyMode.ExecutionAndPublication);

            this.mageKnight = new Lazy <IMageKnightModel>(
                this.CreateMageKnight,
                LazyThreadSafetyMode.ExecutionAndPublication);

            this.userProxyFactory = new Lazy <IUserModelProxyFactory>(
                this.CreateUserProxyFactory,
                LazyThreadSafetyMode.ExecutionAndPublication);

            this.user = new Lazy <IUserModel>(
                this.CreateUser,
                LazyThreadSafetyMode.ExecutionAndPublication);

            this.userCollectionProxyFactory = new Lazy <IUserCollectionProxyFactory>(
                this.CreateUserCollectionProxyFactory,
                LazyThreadSafetyMode.ExecutionAndPublication);

            this.userCollection = new Lazy <IUserCollection>(
                this.CreateUserCollection,
                LazyThreadSafetyMode.ExecutionAndPublication);

            this.gameProxyFactory = new Lazy <IGameModelProxyFactory>(
                this.CreateGameProxyFactory,
                LazyThreadSafetyMode.ExecutionAndPublication);

            this.game = new Lazy <IGameModel>(
                this.CreateGame,
                LazyThreadSafetyMode.ExecutionAndPublication);

            this.gamesProxyFactory = new Lazy <IGamesModelProxyFactory>(
                this.CreateGamesProxyFactory,
                LazyThreadSafetyMode.ExecutionAndPublication);

            this.games = new Lazy <IGameModels>(
                this.CreateGames,
                LazyThreadSafetyMode.ExecutionAndPublication);
        }