public IEnumerable <Type> GetAllHandlers(params Assembly[] assemblies) { List <Type> handlers = new List <Type>(); var assembliesToScan = assemblies.Distinct().ToList(); if (assembliesToScan.Count == 0) { assembliesToScan.Add(Assembly.GetExecutingAssembly()); } foreach (var assembly in assembliesToScan) { var ttHandlers = assembly.DefinedTypes .Where(t => TypeTasqReference.IsConcrete(t) && TypeTasqReference.IsValidHandler(t)) .Select(a => TypeTasqReference.Resolve(a)) .ToList(); foreach (var ttHandler in ttHandlers) { handlers.Add(ttHandler.HandlerImplementation); } } return(handlers); }
public virtual void RegisterFromAssembly(params Assembly[] assemblies) { var handlers = GetAllHandlers(assemblies); foreach (var handler in handlers) { Register(TypeTasqReference.Resolve(handler)); } }
public static TasqHandlerDetail TryGetFromType(Type type, ITasqHandlerResolver handlerResolver) { if (!TypeTasqReference.IsValidHandler(type)) { return(null); } var reference = TypeTasqReference.Resolve(type); return(new TasqHandlerDetail { Handler = (ITasqHandler)handlerResolver.GetService(reference), Reference = reference }); }
public virtual void Register <THandler>() where THandler : ITasqHandler { Register(TypeTasqReference.Resolve <THandler>()); }