예제 #1
0
        public static IServiceCollection AddPlanningPokerClient(this IServiceCollection services, IConfigurationRoot configuration)
        {
            services.Configure <PokerConnectionSettings>(options => configuration.GetSection("PokerConnectionSettings").Bind(options));

            var validatedConfiguration = IServiceCollectionExtension.ValidateAndRetrieveConfiguration(configuration);

            var connectionSettings = new PokerConnectionSettings(
                validatedConfiguration.PlanningSocketUri,
                validatedConfiguration.PlanningApiUri,
                validatedConfiguration.PlanningApiKey
                );
            var connectionSettingsOptions = Options.Create(connectionSettings);

            var messageParser = new MessageParser();

            services.AddSingleton(typeof(MessageParser), messageParser);

            var responseMessageFactories = new List <IResponseMessageFactory>();

            responseMessageFactories.Add(new NewSessionResponseMessageFactory(messageParser));
            responseMessageFactories.Add(new SubscribeSessionResponseMessageFactory(messageParser));
            responseMessageFactories.Add(new JoinSessionResponseMessageFactory(messageParser));
            responseMessageFactories.Add(new RefreshSessionMessageFactory(messageParser));
            responseMessageFactories.Add(new EndSessionClientMessageFactory(messageParser));

            var responseMessageParser = new ResponseMessageParser(messageParser, responseMessageFactories);

            services.AddSingleton(typeof(IResponseMessageParser), responseMessageParser);

            var planningPokerSocket = new PlanningPokerSocket(connectionSettingsOptions);

            services.AddSingleton(typeof(IPokerConnection), planningPokerSocket);

            var userCacheProvider = new UserCacheProvider();

            services.AddSingleton(typeof(UserCacheProvider), userCacheProvider);

            var httpClient = new HttpClient();

            services.AddSingleton(typeof(HttpClient), httpClient);
            var planningPokerApiService = new PlanningPokerApiService(httpClient, connectionSettingsOptions);

            services.AddSingleton(typeof(IPlanningPokerService), planningPokerApiService);

            var planningPokerConnectionFactory = new PlanningConnectionFactory(connectionSettingsOptions,
                                                                               responseMessageParser, planningPokerSocket, userCacheProvider, planningPokerApiService);

            services.AddSingleton(typeof(IPlanningConnectionFactory), planningPokerConnectionFactory);
            services = AddResponseMessageFactories(services);

            return(services);
        }
예제 #2
0
        public GetTests()
        {
            _messageParser = new MessageParser();

            var responseMessageFactories = new List <IResponseMessageFactory>();

            responseMessageFactories.Add(new NewSessionResponseMessageFactory(_messageParser));
            responseMessageFactories.Add(new SubscribeSessionResponseMessageFactory(_messageParser));
            responseMessageFactories.Add(new JoinSessionResponseMessageFactory(_messageParser));
            responseMessageFactories.Add(new RefreshSessionMessageFactory(_messageParser));
            responseMessageFactories.Add(new EndSessionClientMessageFactory(_messageParser));

            _responseMessageFactory = new ResponseMessageParser(_messageParser, responseMessageFactories);
        }