Exemplo n.º 1
0
        /// <summary>
        /// Formalize a HyperDynamo using a HyperDictionary into a concrete class
        /// called HyperHypo (Hyper - more than C#; Hypo - less than JavaScript)
        /// </summary>
        private static void HelloHyperHypo()
        {
            Console.WriteLine("Using HyperDynamo with HyperDictionary membership provider\n==========================================================");

            Console.WriteLine("First example: prototype inheritance where only one.Whassup is set");
            dynamic one = new HyperHypo();
            one.Whassup = new Func<string>(SayHello);
            Console.WriteLine("one.Whassup(): {0}", one.Whassup());

            //two inherits from one (set's it's prototype)
            dynamic two = new HyperHypo(one);
            two.HowsItGoing = new Func<string, string>(name => String.Format("How's it going, {0}?", name));
            Console.WriteLine("two.Whassup(): {0}", two.Whassup());
            Console.WriteLine("two.HowsItGoing(\"buddy\"): {0}", two.HowsItGoing("buddy"));
            Pause();
        }