Exemple #1
0
    static void Main(string[] args)
    {
        dynamic father = new Proto();

        father.FirstName = "Adam";
        father.LastName = "Smith";
        father.Address = "Seattle, WA";
        father.Introduce = (Action<dynamic>)(o => Console.WriteLine("{0} {1} from {2}", o.FirstName, o.LastName, o.Address));

        father.Introduce();

        dynamic daughter = father.Spawn();
        daughter.FirstName = "Caroline";
        daughter.Introduce();

        // let's marry Caroline off...
        daughter.LastName = "Stiller";
        daughter.Address = "Minneapolis, MI";
        daughter.Introduce();

        // time for some grand-children
        dynamic grandson = daughter.Spawn();
        grandson.FirstName = "Tim";
        dynamic granddaughter = daughter.Spawn();
        granddaughter.FirstName = "Synthia";

        // whoops, house burned down.
        // family goes back to live with the grandparents
        daughter.DeleteMember("Address");
        granddaughter.Introduce();
    }