private Controller CreateController(string name) { name = name.ToUpper(); CacheTable <Type> cache = new CacheTable <Type>(Utility.ControllerTypeCacheName); Type type = cache[name]; if (type == null) { int index; string asm; DirectoryInfo dir = new DirectoryInfo(Context.Server.MapPath("~/Bin")); FileInfo[] files = dir.GetFiles("*.dll", SearchOption.TopDirectoryOnly); foreach (FileInfo file in files) { index = file.Name.LastIndexOf('.'); asm = file.Name.Substring(0, index); type = Type.GetType(string.Concat(asm, ".Controllers.Extension.", name, ',', asm), false, true); if (type != null) { cache[name] = type; break; } } if (type == null) { foreach (FileInfo file in files) { index = file.Name.LastIndexOf('.'); asm = file.Name.Substring(0, index); type = Type.GetType(string.Concat(asm, ".Controllers.", name, ',', asm), false, true); if (type != null) { cache[name] = type; break; } } } } if (type != null) { return(Activator.CreateInstance(type) as Controller); } return(null); }
public static T Get(string name, object key) { CacheTable <T> ct = new CacheTable <T>(name); return(ct[key]); }
public static void Set(string name, object key, T value) { CacheTable <T> ct = new CacheTable <T>(name); ct[key] = value; }