GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — dotNET.Lab/DesignPatterns/DesignPattern.Proxy/Program.cs at main · heliomarpm/dotNET.Lab Expand file tree/ Copy pathProgram.csMore file actions 91 lines (68 loc) · 2.76 KB / Copy pathProgram.csFile metadata and controls91 lines (68 loc) · 2.76 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 using System; namespace Proxy { class Program { static void Main(string[] args) { if (System.IO.File.Exists("Leiame.txt")) { string[] linhas = System.IO.File.ReadAllLines(@"Leiame.txt"); foreach (var linha in linhas) { if (linha.StartsWith("\t")) Console.ForegroundColor = ConsoleColor.White; else Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine(linha); } Console.WriteLine(new String('=', 100)); Console.WriteLine(); Console.WriteLine(); Console.ResetColor(); } Console.WriteLine("\n----Exemplo 01------------------------------"); Console.WriteLine("Sem proxy\n---------\n"); for (int i = 1; i <= 3; i++) { Usuario usuario = new Usuario(); Console.WriteLine(usuario.Consultar()); Console.WriteLine(); } Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Usando proxy para controlar a criação"); Console.WriteLine("-------------------------------------"); Console.WriteLine(); IUsuario proxy; proxy = new UsuarioProxy(); for (int i = 1; i <= 3; i++) { Console.WriteLine(proxy.Consultar()); Console.WriteLine(); } Console.ReadKey(); Console.WriteLine("\n----Exemplo 02------------------------------"); Console.WriteLine("Sem proxy\n---------\n"); Usuario usuario2 = new Usuario(); Console.WriteLine(usuario2.Consultar()); Console.WriteLine("\n\n\n"); Console.WriteLine("Usando proxy para controlar acesso"); Console.WriteLine("----------------------------------"); Console.WriteLine(); UsuarioProxy2 proxy2 = new UsuarioProxy2(); //tentando consultar sem autenticar Console.WriteLine(proxy2.Consultar()); Console.WriteLine(); //autenticando com senha incorreta Console.WriteLine(proxy2.Autenticar("senhaErrada")); Console.WriteLine(proxy2.Consultar()); Console.WriteLine(); //agora, sim... Console.WriteLine(proxy2.Autenticar("53NH4")); Console.WriteLine(proxy2.Consultar()); Console.WriteLine(); Console.ReadKey(); } } } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |