New Code to HTML Addin for Visual Studio 2008 and Windows Live Writer

There’s a new Code to HTML Addin for Visual Studio 2008 and a Plugin for Windows live writer from the same author.
I saw it mentioned by MSDN News on Twitter today and I had to download and install it out of curiosity.
The result looks great. What do you think?

 

Code Snippet
  1. using System;
  2. using System.Xml.Schema;
  3. using DotNetExpansions.IO;
  4.  
  5. namespace WithValidation
  6. {
  7.    internal class Program
  8.    {
  9.       private static void Main()
  10.       {
  11.          // Variation for use with Validation.
  12.          var config = new Configuration4Validation
  13.                           {
  14.                              BackGroundColorSettings = new Configuration4Validation.BackGroundColor
  15.                                                           {
  16.                                                              R = 255,
  17.                                                              G = 255,
  18.                                                              B = 255
  19.                                                           },
  20.                              FontColorSettings = new Configuration4Validation.FontColor
  21.                                                     {
  22.                                                        R = 0,
  23.                                                        G = 0,
  24.                                                        B = 0
  25.                                                     },
  26.                              UserFont = new Configuration4Validation.FontParams
  27.                                            {
  28.                                               Name = "Calibri",
  29.                                               Size = 12
  30.                                            },
  31.                              WindowSettings = new Configuration4Validation.WindowParams
  32.                                                  {
  33.                                                     Height = 600,
  34.                                                     Width = 800,
  35.                                                     X = 300,
  36.                                                     Y = 200
  37.                                                  }
  38.                           };
  39.  
  40.          var configManager = new XmlIo(Environment.CurrentDirectory, "config.xml");
  41.          // Saving your configuration to the XML file.
  42.          configManager.Save(config);
  43.  
  44.          // Loading a configuration with validation
  45.          configManager.ValidationEvent += OnValidationEvent;
  46.          Configuration4Validation newConfig;
  47.          try
  48.          {
  49.             if(configManager.FileIsValidWith("configSchema.xsd"))
  50.                newConfig = configManager.Load<Configuration4Validation>();
  51.             else
  52.                DoSomethingAppropriate();
  53.          }
  54.          catch(XmlSchemaValidationException problem)
  55.          {
  56.             Console.WriteLine(problem.ToString());
  57.          }
  58.  
  59.          // Verhindert das selbsttätige Schließen des Konsolenfensters.
  60.          Console.WriteLine("\nPress any key to terminate the program.");
  61.          Console.ReadKey();
  62.       }
  63.  
  64.       // Only needed when validation is involved.
  65.       private static void OnValidationEvent(object sender, System.Xml.Schema.ValidationEventArgs e)
  66.       {
  67.          // Just a demo. Do something appropriate with the event.
  68.          Console.WriteLine(e.Exception);
  69.          Console.WriteLine(e.Message);
  70.          Console.WriteLine(e.Severity);
  71.       }
  72.  
  73.       // Only needed when validation is involved.
  74.       private static void DoSomethingAppropriate()
  75.       {
  76.          // Do something appropriate.
  77.       }
  78.    }
  79. }

Code Snippet
  1. using System;
  2. using System.Drawing;
  3. using DotNetExpansions.IO;
  4.  
  5. namespace WithoutValidation
  6. {
  7.    internal class Program
  8.    {
  9.       private static void Main()
  10.       {
  11.          // Variation for use without validation.
  12.          var config = new Configuration
  13.                          {
  14.                             BackgroundColor = .FromArgb(255, 255, 255),
  15.                             FontColor = .FromArgb(0, 0, 0),
  16.                             UserFont = new Font("Calibri", 12),
  17.                             WindowLocation = new (300, 200),
  18.                             WindowSize = new (800, 600)
  19.                          };
  20.         
  21.  
  22.          var configManager = new XmlIo(Environment.CurrentDirectory, "config.xml");
  23.          // Saving your configuration to the XML file.
  24.          configManager.Save(config);
  25.  
  26.          // Loading your configuration from the xml file.
  27.          Configuration newConfig = configManager.Load<Configuration>();
  28.  
  29.          // Verhindert das selbsttätige Schließen des Konsolenfensters.
  30.          Console.WriteLine("\nPress any key to terminate the program.");
  31.          Console.ReadKey();
  32.       }
  33.    }
  34. }

By the way, the code in these boxes are quick reference demos for the XmlIO class, which is part of my .Net Expansions Framework. You can download the latest release at http://cyrons.svn.beanstalkapp.com/general/DotNetExpansions/tags. The framework comes along with complete intellisense support and a compiled help file (.chm).

DotNetKicks-DE Image
Published Donnerstag, 17. September 2009 20:47 von Rainer Hilmer

Kommentare

Keine Kommentare

Kommentar abgeben

(verpflichtend) 
(verpflichtend) 
(optional)
(verpflichtend)