public static MvcCommandRegistrar BuildCommandRegistrarForHandler(Type handler) { var interfaceType = handler.FindFirstInterfaceThatCloses(typeof(ICommandHandler<>)); var commandMessageTypeOne = interfaceType.GetGenericArguments()[0]; return new MvcCommandRegistrar(commandMessageTypeOne); }
private Type GetLeastSpecificButValidType(Type pluginType, Type type) { if (pluginType.IsGenericTypeDefinition && !type.IsOpenGeneric()) return type.FindFirstInterfaceThatCloses(pluginType); return pluginType; }
public static MvcQueryRegistrar BuildQueryRegistrarForCrudCommand(Type query, Type genericCommand) { Type interfaceType = query.FindFirstInterfaceThatCloses(genericCommand); Type domainEntityType = interfaceType.GetGenericArguments()[0]; return new MvcQueryRegistrar(query, domainEntityType); }
public void Process(Type type, Registry registry) { Type interfaceType = type.FindFirstInterfaceThatCloses(_openGenericType); if (interfaceType != null) { registry.AddType(interfaceType, type); } }
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); }
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); } }
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); } }
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); } }
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); } }
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); }