コード例 #1
0
ファイル: Program.cs プロジェクト: witz0207/di-book-support
        public void Login(string userId, string pwd)
        {
            var msgService  = MyDIContainer.Resolve <IMessageService>();
            var authService = new AuthenticationService(msgService); // 注入相依物件。

            if (authService.TwoFactorLogin(userId, pwd))
            {
                // 與主題無關,故省略。
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: DakaoBit/exDI
        public void Login(string userId, string pwd)
        {
            var msgService  = MyDIContainer.Resolve <IMessageService>();
            var authService = new AuthenticationService(msgService); // 注入相依物件。

            if (authService.TwoFactorLogin(userId, pwd))
            {
                // 請使用者收信,然後回來輸入信中提示的驗證碼。
                string userInputToken = "123456";
                if (authService.VerifyToken(userInputToken))
                {
                    // 登入成功。
                }
            }
            // 登入失敗。
        }