Esempio n. 1
0
 public SimpleDependencyInjection RegisterType <T>(CreationRules creationRules)
 {
     _container.Add(typeof(T), new TypeContainer {
         Rule = creationRules
     });
     return(this);
 }
Esempio n. 2
0
 public SimpleDependencyInjection RegisterType <TInterface, TImplementation>(CreationRules creationRules)
     where TImplementation : TInterface
 {
     _container.Add(typeof(TInterface), new TypeContainer {
         Rule = creationRules, Implementation = typeof(TImplementation)
     });
     return(this);
 }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
 public LeadValidator(CreationRules creation, INotificationHandler notificationHandler) //  <- Injetando mais abstrações para validação, se necessario.
     : base(notificationHandler)
 {
     _creation = creation;
 }