Пример #1
0
        public void UseDependency()
        {
            ConsoleLogService   logSvc   = new ConsoleLogService(LogType.Info);
            OutlookEmailService emailSvc = new OutlookEmailService();
            Dependency1         dep      = new Dependency1(logSvc, emailSvc);

            dep.DoStuff();
        }
        public static void DependencyInjection()
        {
            ////Dependency Injection
            ///
            //Constructor injection example
            var googleEmailService            = new GoogleEmailService();
            var userLogicConstructorInjection = new UserLogicConstructorInjection(googleEmailService);

            //Setter injection
            OutlookEmailService outlookEmailService = new OutlookEmailService();
            var userLogicSetter = new UserLogicSetterInjection()
            {
                EmailService = outlookEmailService
            };

            //Method injection
            OutlookEmailService outlookEmailService2 = new OutlookEmailService();
            var userLogicMethod = new UserLogicMethodInjection();

            userLogicMethod.Register("*****@*****.**", "Test12345", outlookEmailService);
        }
 public UserLogicBadExample2()
 {
     _authService  = new OutlookOAuthService();
     _emailService = new OutlookEmailService();
 }