Exemple #1
0
        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;
        }
Exemple #2
0
		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;
		}
Exemple #3
0
 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));
         }
     };
 }
Exemple #4
0
        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);
        }
Exemple #5
0
 public SqliteSection(SqliteDictionary dict, int section)
     : base(dict)
 {
     this.section = section;
 }
Exemple #6
0
 public Section(SqliteDictionary dict, bool forwards)
 {
     this.dict = dict;
     this.forwards = forwards;
 }
Exemple #7
0
 public SqliteSection(SqliteDictionary dict, int section) : base(dict)
 {
     this.section = section;
 }
Exemple #8
0
 public Section(SqliteDictionary dict, bool forwards)
 {
     this.dict     = dict;
     this.forwards = forwards;
 }