public SimpleDependencyInjection RegisterType <T>(CreationRules creationRules) { _container.Add(typeof(T), new TypeContainer { Rule = creationRules }); return(this); }
public SimpleDependencyInjection RegisterType <TInterface, TImplementation>(CreationRules creationRules) where TImplementation : TInterface { _container.Add(typeof(TInterface), new TypeContainer { Rule = creationRules, Implementation = typeof(TImplementation) }); return(this); }
public SimpleDependencyInjection RegisterInterface <TInterface>(CreationRules creationRules) { var tInterface = typeof(TInterface); var implementation = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(s => s.GetTypes()) .Where(p => tInterface.IsAssignableFrom(p)) .Where(p => !p.IsInterface) .FirstOrDefault(); if (implementation == null) { throw new Exception("No implementation found"); } _container.Add(tInterface, new TypeContainer { Rule = creationRules, Implementation = implementation }); return(this); }
public LeadValidator(CreationRules creation, INotificationHandler notificationHandler) // <- Injetando mais abstrações para validação, se necessario. : base(notificationHandler) { _creation = creation; }