public static void ToXml(this IExpression expression, XmlTextWriter writer) { if (null == expression) { throw new ArgumentNullException("expression"); } if (null == writer) { throw new ArgumentNullException("writer"); } Configuration config = new Configuration(); IConfigurationElement configElement = config.AddSection("expression extensions").AddElement("expression"); expression.ToConfiguration(configElement); configElement.WriteXml(writer); }