Esempio n. 1
0
        private static void Main()
        {
            /* Replace the hard-coded initialization of ConsoleMessageWriter with the below three
             * statements to use an example of Constrained Construction late binding. */
            //var typeName = 
            //    ConfigurationManager.AppSettings["messageWriter"];
            //var type = Type.GetType(typeName, true);
            //IMessageWriter writer = 
            //    (IMessageWriter)Activator.CreateInstance(type);

            /* Replace the hard-coded initialization of ConsoleMessageWriter with the below two
             * statements to use an example of a Decorator. */
            //Thread.CurrentPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
            //IMessageWriter writer = 
            //    new SecureMessageWriter(
            //        new ConsoleMessageWriter());

            IMessageWriter writer = new ConsoleMessageWriter();
            var salutation = new Salutation(writer);
            salutation.Exclaim();
        }
Esempio n. 2
0
        private static void Main()
        {
            /* Replace the hard-coded initialization of ConsoleMessageWriter with the below three
             * statements to use an example of Constrained Construction late binding. */
            //var typeName =
            //    ConfigurationManager.AppSettings["messageWriter"];
            //var type = Type.GetType(typeName, true);
            //IMessageWriter writer =
            //    (IMessageWriter)Activator.CreateInstance(type);

            /* Replace the hard-coded initialization of ConsoleMessageWriter with the below two
             * statements to use an example of a Decorator. */
            //Thread.CurrentPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
            //IMessageWriter writer =
            //    new SecureMessageWriter(
            //        new ConsoleMessageWriter());

            IMessageWriter writer     = new ConsoleMessageWriter();
            var            salutation = new Salutation(writer);

            salutation.Exclaim();
        }