public static IEnumerable <DictionaryInfo> GetAll() { foreach (FileInfo file in DataStore.CombinedDataStore.GetFiles (Configuration.DictionariesFolderName, new System.Text.RegularExpressions.Regex(@"\.dictx?$"), true)) { DictionaryInfo info = null; try { if (file.Extension == ".dictx") { using (var dict = SqliteDictionary.FromPath(file.FullName)) info = dict.Info; } else { info = new SimpleDictionary.Info(file.FullName); } } catch (IOException e) { ProgramLog.Default.AddMessage(LogType.Warning, "Failed loading dictionary info for {0}: {1}", file.FullName, e.Message); } if (info != null) { yield return(info); } } yield break; }
public DictionaryInfo() { // This needs a default: for example, JSON-serialized DictionaryInfo objects might not have it. // Maybe it shouldn't be a delegate after all. LookupForm makes sure the dictionary is deallocated // after closing anyway, so it's not like the weak reference does anything. GetFullInstance = delegate() { if (Path.EndsWith(".dictx")) { return(SqliteDictionary.FromPath(Path)); } else { return(new SimpleDictionary(Path)); } }; }