Exemplo n.º 1
0
        public SqliteWordList CreateSet(string name, string author, string language, string url, DateTime?date)
        {
            long setID;

            using (var txn = Connection.BeginTransaction()) {
                ExecuteSQL("INSERT INTO Sets (Name, Author, Language, Url, Created) VALUES (?, ?, ?, ?, ?)",
                           name, author, language, url, date.HasValue ? (object)date.Value : (object)DBNull.Value);

                setID = GetLastInsertRowID();
                txn.Commit();
            }

            var wl = SqliteWordList.FromSetID(this, setID);

            if (wl == null)
            {
                return(null);
            }
            wordLists[setID] = new NullWeakReference <SqliteWordList>(wl);
            return(wl);
        }
Exemplo n.º 2
0
        /// <param name="setID">The SetID of the word list</param>
        /// <returns>An existing SqliteWordList instance, if one exists, otherwise a newly-created SqliteWordList.</returns>
        public SqliteWordList GetWordList(long setID)
        {
            SqliteWordList wl = null;
            NullWeakReference <SqliteWordList> list;

            if (wordLists.TryGetValue(setID, out list))
            {
                wl = list.Target;
            }

            if (wl != null)
            {
                return(wl);
            }

            wl = SqliteWordList.FromSetID(this, setID);
            if (wl == null)
            {
                return(null);
            }

            wordLists[setID] = new NullWeakReference <SqliteWordList>(wl);
            return(wl);
        }