コード例 #1
0
        public static MvcCommandRegistrar BuildCommandRegistrarForHandler(Type handler)
        {
            var interfaceType = handler.FindFirstInterfaceThatCloses(typeof(ICommandHandler<>));
            var commandMessageTypeOne = interfaceType.GetGenericArguments()[0];

            return new MvcCommandRegistrar(commandMessageTypeOne);
        }
コード例 #2
0
        private Type GetLeastSpecificButValidType(Type pluginType, Type type)
        {
            if (pluginType.IsGenericTypeDefinition && !type.IsOpenGeneric())
                return type.FindFirstInterfaceThatCloses(pluginType);

            return pluginType;
        }
コード例 #3
0
        public static MvcQueryRegistrar BuildQueryRegistrarForCrudCommand(Type query, Type genericCommand)
        {
            Type interfaceType = query.FindFirstInterfaceThatCloses(genericCommand);
            Type domainEntityType = interfaceType.GetGenericArguments()[0];

            return new MvcQueryRegistrar(query, domainEntityType);
        }
コード例 #4
0
 public void Process(Type type, Registry registry)
 {
     Type interfaceType = type.FindFirstInterfaceThatCloses(_openGenericType);
     if (interfaceType != null)
     {
         registry.AddType(interfaceType, type);
     }
 }
コード例 #5
0
        public static MvcQueryRegistrar BuildQueryRegistrarForHandler(Type handler)
        {
            var interfaceType = handler.FindFirstInterfaceThatCloses(typeof(IQueryHandler<,>));
            var commandMessageTypeOne = interfaceType.GetGenericArguments()[0];
            var commandMessageTypeTwo = interfaceType.GetGenericArguments()[1];

            return new MvcQueryRegistrar(commandMessageTypeOne, commandMessageTypeTwo);
        }
コード例 #6
0
        private static void RegisterTypes(Type type, Registry registry, Type genericCommand, Type handler, Type handlerInterface)
        {
            if (type.ImplementsInterfaceTemplate(genericCommand))
            {
                Type interfaceType = type.FindFirstInterfaceThatCloses(genericCommand);
                Type domainEntityType = interfaceType.GetGenericArguments()[0];

                Type closesCommandHandlerInterface = handlerInterface.MakeGenericType(type, domainEntityType);
                Type closesCommandHandler = handler.MakeGenericType(type, domainEntityType);

                registry.For(closesCommandHandlerInterface)
                    .Add(closesCommandHandler);
            }
        }
コード例 #7
0
        public void Process(Type type, Registry registry)
        {
            if (type.ImplementsInterfaceTemplate(typeof(ICreateCommand<>)))
            {
                Type interfaceType = type.FindFirstInterfaceThatCloses(typeof(ICreateCommand<>));
                Type domainEntityType = interfaceType.GetGenericArguments()[0];

                var openIdGeneratorType = typeof(IIdGenerator<,>);
                var closedIdGeneratorType =
                    openIdGeneratorType.MakeGenericType(domainEntityType, typeof(Guid?));

                var openGuidGenerator = typeof(GuidIdGenerator<>);
                var closedGuidIdGenerator = openGuidGenerator.MakeGenericType(domainEntityType);

                registry.For(closedIdGeneratorType).Use(closedGuidIdGenerator);
            }
        }
コード例 #8
0
        public void ProcessHandler(Type type, Registry registry, Type typeInterface, Type handlerInterface, Type concreteHandler)
        {
            if (type.ImplementsInterfaceTemplate(typeInterface))
            {
                Type interfaceType = type.FindFirstInterfaceThatCloses(typeInterface);
                Type[] genericArguments = interfaceType.GetGenericArguments();

                Type closeActionProcessprInterface =
                    handlerInterface.MakeGenericType(genericArguments);

                Type closesActionProcessor =
                    concreteHandler.MakeGenericType(genericArguments);

                registry.For(closeActionProcessprInterface).Use(closesActionProcessor);
                registry.AddType(interfaceType, type);
            }
        }
コード例 #9
0
        public void ProcessFacade(Type type, Registry registry, Type facadeInterface, Type genericFacadeInterface, Type concreteFacade)
        {
            if (type.ImplementsInterfaceTemplate(genericFacadeInterface))
            {
                var interfaceType = type.FindFirstInterfaceThatCloses(genericFacadeInterface);
                var commandMessageTypes = interfaceType.GetGenericArguments();

                var closesQuerryProcessor =
                    concreteFacade.MakeGenericType(commandMessageTypes);

                registry.AddType(closesQuerryProcessor);
                registry.AddType(interfaceType, type);
            }
            if (facadeInterface.IsAssignableFrom(type) && !type.IsInterface)
            {
                registry.AddType(facadeInterface, type);
            }
        }
コード例 #10
0
        public void Process(Type type, Registry registry)
        {
            if (!type.ImplementsInterfaceTemplate(typeof (IFormHandler<>))) return;

            var interfaceType = type.FindFirstInterfaceThatCloses(typeof (IFormHandler<>));
            var commandMessageType = interfaceType.GetGenericArguments()[0];

            var openCommandMethodResultType = typeof (FormActionResult<>);
            var closedCommandMethodResultType = openCommandMethodResultType.MakeGenericType(commandMessageType);

            var openActionMethodInvokerType = typeof (IActionMethodResultInvoker<>);
            var closedActionMethodInvokerType =
                openActionMethodInvokerType.MakeGenericType(closedCommandMethodResultType);

            var openCommandMethodResultInvokerType = typeof (CommandMethodResultInvoker<>);
            var closedCommandMethodResultInvokerType =
                openCommandMethodResultInvokerType.MakeGenericType(commandMessageType);

            registry.For(closedActionMethodInvokerType).Use(closedCommandMethodResultInvokerType);
        }