Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            ContainerContext.Load();

            IBankAccountService productService = BankAccountServiceFactory.CreateTransparentProxy();

            int branchCode = 1, accountNumber = 1000;

            //servis üzerinden normal şekilde veriler gelecek
            BankAccountCollection bankAccounts = productService.GetBankAccounts(branchCode);

            foreach (var bankAccount in bankAccounts)
            {
                Console.WriteLine(bankAccount.ToString());
            }

            //cache üzerinden gelecek
            bankAccounts = productService.GetBankAccounts(branchCode);
            foreach (var bankAccount in bankAccounts)
            {
                Console.WriteLine(bankAccount.ToString());
            }

            Run(() =>
            {
                //[Authorize] içerinde Admin userı çalıştırabilir sadece
                productService.WithDraw(accountNumber, 200000);
            });

            Run(() =>
            {
                //[Exception] attribute için hata fırlatıyoruz içeride
                productService.Deposit(accountNumber, 200000);
            });

            Console.ReadLine();
        }