Ejemplo n.º 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;
        }
Ejemplo n.º 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;
		}
Ejemplo n.º 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));
         }
     };
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 5
0
 public SqliteSection(SqliteDictionary dict, int section)
     : base(dict)
 {
     this.section = section;
 }
Ejemplo n.º 6
0
 public Section(SqliteDictionary dict, bool forwards)
 {
     this.dict = dict;
     this.forwards = forwards;
 }
Ejemplo n.º 7
0
 public SqliteSection(SqliteDictionary dict, int section) : base(dict)
 {
     this.section = section;
 }
Ejemplo n.º 8
0
 public Section(SqliteDictionary dict, bool forwards)
 {
     this.dict     = dict;
     this.forwards = forwards;
 }