Example #1
0
        private static Dictionary <Type, dynamic> CreateQueryHandlers(KrakenEndpoint endpoint)
        {
            Dictionary <Type, dynamic> queryHandlers = new Dictionary <Type, dynamic>();

            //List<Type> queryTypes = (from assembly in AppDomain.CurrentDomain.GetAssemblies()
            //                         from type in assembly.GetTypes()
            //                         where TypeIsQueryType(type) &&
            //                         !type.IsAbstract
            //                         select type).ToList();

            var handlers = ReflectionExtensions.GetImplementationsOfAbstractType(typeof(KrakenQueryHandler <,>), AppDomain.CurrentDomain.GetAssemblies())
                           .Where(t => !t.IsGenericTypeDefinition).ToList();

            foreach (Type handlerType in handlers)
            {
                MethodInfo handleMethod = handlerType.GetMethod("HandleAsync");
                Type       queryType    = handleMethod.GetParameters()[0].ParameterType;
                Type       responseType = handleMethod.ReturnType.GenericTypeArguments[0];

                object handler = Activator.CreateInstance(handlerType, endpoint);

                Type   decoratorType = typeof(RetryQueryDecorator <,>).MakeGenericType(queryType, responseType);
                object decorated     = Activator.CreateInstance(decoratorType, handler);

                queryHandlers.Add(queryType, (dynamic)decorated);
            }

            return(queryHandlers);
        }
Example #2
0
        public Kraken(KrakenEndpoint endpoint)
        {
            this.endpoint = endpoint;

            queryHandlers   = CreateQueryHandlers(endpoint);
            commandHandlers = CreateCommandHandlers(endpoint);
        }
Example #3
0
        public TwitchClient(string clientID, string clientSecret, string registeredRedirectUri, string[] requiredScopes)
        {
            ID     = clientID;
            Secret = clientSecret;
            RegisteredRedirectUri = registeredRedirectUri;
            RequiredScopes        = requiredScopes;

            Auth          = new AuthEndpoint(this);
            Authenticator = new Authenticator(this);
            Kraken        = new KrakenEndpoint(this, Authenticator);

            V5 = new Kraken(Kraken);
        }
 public GetChannelInfoQueryHandler(KrakenEndpoint endpoint) : base(endpoint)
 {
 }
Example #5
0
 public GetGamesByNameQueryHandler(KrakenEndpoint endpoint) : base(endpoint)
 {
 }
 public UpdateChannelInfoCommandHandler(KrakenEndpoint endpoint) : base(endpoint)
 {
 }
 public KrakenQueryHandler(KrakenEndpoint endpoint)
 {
     Endpoint = endpoint;
 }
Example #8
0
 public KrakenCommandHandler(KrakenEndpoint endpoint)
 {
     Endpoint = endpoint;
 }