Tuesday, June 10, 2008

Live Writer Test Post

Microsoft just released a technical preview of the newest version of Windows Live Writer.  Since this has a couple of features I’ve really been looking for, I’m going to try it out.  If it works well, I’ll start using it for all my (very infrequent) posts.  I apologize in advance for all the random content – I just want to try out the new features to make sure they work how I want them to.

Here’s a picture:

IMG_2049 

Here’s a table:

Heading 1 Heading 2
Row 1 Column 1 Row 1 Column 2

Here’s a map (our old house in Tucson):

Map image

Here is a video:

Emily's Birthday

Here is a code snippet:

   1: using System;


   2: using System.Collections;


   3: using System.Reflection;


   4:  


   5: namespace ExternalDSL {


   6:   public class DslExecuter {


   7:     private readonly Hashtable parameters = new Hashtable(StringComparer.InvariantCultureIgnoreCase);


   8:  


   9:     public void AddParameter(string name, object parameter) {


  10:       parameters[name] = parameter;


  11:     }


  12:  


  13:     public object Invoke(ActionExpression expression) {


  14:       object obj = parameters[expression.Left];


  15:       if (obj == null)


  16:         throw new InvalidOperationException("Could not find parameter with name: " + expression.Left);


  17:       MethodInfo method =


  18:         obj.GetType().GetMethod(expression.Operator,


  19:                                 BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Public);


  20:       if (method == null)


  21:         throw new InvalidOperationException("Could not find method operator " + expression.Operator + " on " +


  22:                                             expression.Left);


  23:       ParameterInfo[] methodParams = method.GetParameters();


  24:       if (methodParams.Length != 1)


  25:         throw new InvalidOperationException(expression.Operator + " should accept a single parameter");


  26:       object converted;


  27:       Type paramType = methodParams[0].ParameterType;


  28:       if (paramType.IsEnum)


  29:         converted = Enum.Parse(paramType, expression.Right, true);


  30:       else


  31:         converted = Convert.ChangeType(expression.Right, paramType);


  32:       return method.Invoke(obj, new object[] {converted});


  33:     }


  34:   }


  35: }