public static void Load(string fileName) { Stream stream = null; AppSettings settings = null; try { IFormatter formatter = new BinaryFormatter(); stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.None); int version = (int)formatter.Deserialize(stream); if (version != VERSION) { throw new Exception("Version mismatch."); } settings = (AppSettings)formatter.Deserialize(stream); Console.WriteLine("Defaults loaded. Version: " + version); } catch (Exception e) { Console.WriteLine("Error loading Defaults, standard loaded: " + e.Message); settings = new AppSettings(); } finally { if (null != stream) { stream.Close(); } } instance = settings; // init template engine TemplatePool.Singleton(Path.Combine(Directory.GetCurrentDirectory(), "tmpl") + Path.DirectorySeparatorChar, 20); }
public static TemplatePool Singleton(string tmplDir, int capacity) { if (pool == null) { lock (objLock) { if (pool == null) { pool = new TemplatePool(tmplDir, capacity); } } } return(pool); }
public static TemplatePool Singleton() { if (pool == null) { lock (objLock) { if (pool == null) { pool = new TemplatePool(); } } } return(pool); }