public Info(SimpleDictionary dict) { Load(dict); // Keep a weak reference to the dictionary. This way we don't have to load the // dictionary again if we re-open it soon after we close it. var weak = new NullWeakReference <SimpleDictionary>(dict); GetFullInstance = () => FromWeak(weak); }
private SimpleDictionary FromWeak(NullWeakReference <SimpleDictionary> weak) { var dict = weak.Target; if (dict != null) { if (!dict.Disposed) { return(dict); } } return(new SimpleDictionary(Path)); }
public static SqliteDictionary FromPath(string path) { // Handle cases where paths are not normalized. path = System.IO.Path.GetFullPath(path); NullWeakReference <SqliteDictionary> weakRef; if (openDicts.TryGetValue(path, out weakRef) && weakRef.IsAlive && weakRef.Target.Connection.State == ConnectionState.Open) { return(weakRef.Target); } var dict = new SqliteDictionary(path); openDicts[path] = new NullWeakReference <SqliteDictionary>(dict); return(dict); }