// Collection of code snippets by Arne Vajhøj // (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) using System; using System.Collections.Generic; using DBCache.DAL; namespace DBCache.Util { public abstract class Utility { protected static IList labels = new List(); protected static IList counters = new List(); protected static IList dals = new List(); private static void Add(string label, string counter, IDAL dal) { labels.Add(label); counters.Add(counter); dals.Add(dal); } protected static void AddAll() { Add("ADO.NET - no app cache", "c1", new DAL_ADONET("MySql.Data.MySqlClient", "Server=localhost;Database=test;User Id=root;Password=")); Add("ADO.NET - local app cache", "c2", new DAL_LocalCache(new DAL_ADONET("MySql.Data.MySqlClient", "Server=localhost;Database=test;User Id=root;Password="))); Add("ADO.NET - remote app cache", "c3", new DAL_RemoteCache(new DAL_ADONET("MySql.Data.MySqlClient", "Server=localhost;Database=test;User Id=root;Password="))); Add("EF - no app cache", "c4", new DAL_EF("MySQL_test")); Add("EF - local app cache", "c5", new DAL_LocalCache(new DAL_EF("MySQL_test"))); Add("EF - remote app cache", "c6", new DAL_RemoteCache(new DAL_EF("MySQL_test"))); Add("NHibernate - no app cache, no Hibernate level 2 cache", "c7", new DAL_NHib(@"C:\Work\nhibcfg_nocache.xml", @"C:\Work\nhibmap.xml")); Add("NHibernate - local app cache, no Hibernate level 2 cache", "c8", new DAL_LocalCache(new DAL_NHib(@"C:\Work\nhibcfg_nocache.xml", @"C:\Work\nhibmap.xml"))); Add("NHibernate - remote app cache, no Hibernate level 2 cache", "c9", new DAL_RemoteCache(new DAL_NHib(@"C:\Work\nhibcfg_nocache.xml", @"C:\Work\nhibmap.xml"))); Add("NHibernate - no app cache, local Hibernate level 2 cache", "c10", new DAL_NHib(@"C:\Work\nhibcfg_localcache.xml", @"C:\Work\nhibmap.xml")); Add("NHibernate - no app cache, remote Hibernate level 2 cache", "c11", new DAL_NHib(@"C:\Work\nhibcfg_remotecache.xml", @"C:\Work\nhibmap.xml")); } protected static void CloseAll() { foreach(IDAL dal in dals) { dal.Close(); } } } }