Running with Code Like with scissors, only more dangerous

6Aug/100

Cool Dynamic Code and Talking at AZDNUG on August 10

I’ll be giving a talk next Tuesday, August 10 at the AZ .NET User Group where I’ll be giving a brief treatment on C# 4.0’s new features and primarily be talking about the cool stuff you can do with dynamic code in C#. 

To whet your appetite, here’s some of the code we’ll be reviewing next week:

        static void Main(string[] args)
        {
            string xmlPath = Path.Combine(Environment.CurrentDirectory, "SampleBooks.xml");
            dynamic xml = new DynamicXml(xmlPath);

            foreach (dynamic child in xml)
            {
                string id = child.id;
                Console.WriteLine("BOOK ID: {0}", id);
                Console.WriteLine(child);
            }

            xml.books.SetDefaultIdentifier("id");
            dynamic vs7 = xml.books["bk112"];
            Console.WriteLine("VS7 Book:");
            Console.WriteLine(vs7);

            Console.WriteLine("Title: {0}", xml.books["bk107"].title);

            xml.books["bk113"] = new { Title = "This is a test", 
                  Description = "This is me adding a new anonymous object " +
                  "to the property of a dynamic object by calling SetIndex.", 
                  Author = "Rob Paveza" };
            xml.SaveAs(Path.Combine(Environment.CurrentDirectory, 
                  "SampleBooks-Output.xml"));

            xml.books["bk113"] = new { Title = "This is a replacement", 
                  Description = "This is me replacing an existing dynamic " +
                  "object's property with a new one by calling SetIndex.", 
                  Author = "Rob Paveza" };
            xml.SaveAs(Path.Combine(Environment.CurrentDirectory, 
                  "SampleBooks-Output2.xml"));

            Console.ReadLine();
        }

The user group is meeting at the Microsoft district office at 2929 N. Central Ave., Phoenix (just north of Thomas on Central).  It’ll be on the 14th floor.  I believe pizza will be served.  More info at AZGroups.org

I hope to see you there!

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

ERROR: si-captcha.php plugin says GD image support not detected in PHP!

Contact your web host and ask them why GD image support is not enabled for PHP.

ERROR: si-captcha.php plugin says imagepng function not detected in PHP!

Contact your web host and ask them why imagepng function is not enabled for PHP.

No trackbacks yet.