public ICommandHandler <T> GetCommand <T>() where T : Command { var handler = ReflactorTools.GetInstance <ICommandHandler <T> >(GetHandlerTypes <T>().ToList().First().FullName, _services.GetService <IEventStorage>()); if (handler == null) { throw new InvalidOperationException($"the handler not registered {nameof(T)}"); } return(handler); }
public IEventHandler <T> GetHandler <T>() where T : Event { var types = GetHanderType <T>().ToList(); //这里处理的并不优雅 //需要加判断语句 IEventHandler <T> handler = default; if (types.First().FullName.Contains("Enterprise")) { handler = ReflactorTools.GetInstance <IEventHandler <T> >(GetHanderType <T>().ToList().First().FullName, _services.GetService(typeof(IRepository <EnterpriseEntity>))); } if (handler == null) { throw new Exception($"The handler was not Registered {nameof(IEventHandler<T>)}"); } return(handler); }