public void RegisterFactory(Type genericCommand, Type factoryInterface, Type factoryInstace) { if (ClassType.ImplementsInterfaceTemplate(genericCommand)) { Type interfaceType = ClassType.FindFirstInterfaceThatCloses(genericCommand); Type domainEntityType = interfaceType.GetGenericArguments()[0]; Type closedFactoryInterface = factoryInterface.MakeGenericType(ClassType, domainEntityType); Type closedFactoryType = factoryInstace.MakeGenericType(ClassType, domainEntityType); Registry.For(closedFactoryInterface).Use(closedFactoryType); } }
public void RegisterTypes(Type genericCommand, Type handler) { if (ClassType.ImplementsInterfaceTemplate(genericCommand)) { Type interfaceType = ClassType.FindFirstInterfaceThatCloses(genericCommand); Type domainEntityType = interfaceType.GetGenericArguments()[0]; Type idType = interfaceType.GetGenericArguments()[1]; Type closesCommandHandlerInterface = RegisterProcessorAndGetHandlerType(domainEntityType); Type closesCommandHandler = handler.MakeGenericType(ClassType, domainEntityType, idType); Registry.For(closesCommandHandlerInterface).Use(closesCommandHandler); Registry.For(genericCommand).Use(ClassType); if (typeof(IRegisterMappings).IsAssignableFrom(closesCommandHandler)) { Registry.For(typeof(IRegisterMappings)).Add(closesCommandHandler); } } }