public object ReadFile(params string[] anyFilenames) { ParameterChecker.CheckNullOrEmpty("FileCache.ReadFile", "anyFilenames", anyFilenames, true); string[] filenames = anyFilenames.Select(file => file.IndexOf("SqlMigratorWinform") != -1 ? file : new FileInfo(file).FullName).ToArray(); string cacheKey = MakeCacheKey(filenames); object obj = HttpRuntime.Cache[cacheKey]; if (obj == null) { lock (LockKey) { obj = HttpRuntime.Cache[cacheKey]; if (obj != null) { return(obj); } try { obj = OnReadFile(filenames); } catch (Exception ex) { Logger.Instance.WriteEntry(ex); } if (obj != null) { } if (IsTraced) { Tracer.Instance.Write(TraceClass, "OnReadFile", new[] { "filenames", "result" }, new[] { filenames, obj }); } } } return(obj); }
public DictionaryEnumerator(IEnumerator <K> keys, IEnumerator <V> values) { ParameterChecker.CheckNull("DictionaryEnumerator", "keys", keys); ParameterChecker.CheckNull("DictionaryEnumerator", "values", values); Keys = keys; Values = values; }
public DictionaryEnumerator(IEnumerator items, Converter <object, K> convertKey, Converter <object, V> convertValue) { ParameterChecker.CheckNull("DictionaryEnumerator", "items", items); ParameterChecker.CheckNull("DictionaryEnumerator", "convertKey", convertKey); ParameterChecker.CheckNull("DictionaryEnumerator", "convertValue", convertValue); Items = items; ConvertKey = convertKey; ConvertValue = convertValue; }
public void Initialize(string category, Dictionary <string, bool> traceItems, Converter <TraceObject, SortedList> onWriteTrace) { ParameterChecker.CheckNull("Tracer.Initialize", "traceItems", traceItems); this.Category = category; this.TraceItems = traceItems; if (onWriteTrace == null) { this.OnWriteTrace = new Converter <TraceObject, SortedList>(this.OnDefaultWriteTrace); } else { this.OnWriteTrace = onWriteTrace; } this._HasInitialized = true; }
public static XmlDocument DataTableToXml(DataTable table) { ParameterChecker.CheckNull("XmlHelper.DataTableToXml", "table", table); if (string.IsNullOrEmpty(table.TableName)) { table.TableName = "Table1"; } using (MemoryStream ms = new MemoryStream()) { table.WriteXml(ms); ms.Position = 0L; XmlDocument doc = new XmlDocument(); doc.Load(ms); return(doc); } }
public FileCache(string cacheKeyPrepend, ReadFileHandler onReadFile) { ParameterChecker.CheckNull("FileCache", "onReadFile", onReadFile); CacheKeyPrepend = cacheKeyPrepend ?? string.Empty; OnReadFile = onReadFile; }