Author: O11Y | Posted on: 8/6/2008 4:01:02 AM | Views : 293

Hello,

I have a static class which reads in an XML file during the static constructor and then provides static access methods to the cached XmlDocument object. So:

public static class MyClass
{
   private static XmlDocument _myDoc;
   static MyClass()
   {
      try
      {
        _myDoc = ReadDocumentFromFileSystem();
      }
   }

   public static string GetSomeValue()
   {
     if ( _myDoc == null)
         throw new Exception("Could not load config");
      .....
     
      XmlNode node  = _myDoc.SelectSingleNode(" ...... ");

  ...

Go to the complete details ...