예제 #1
0
파일: Sqlite.cs 프로젝트: aata/szotar
        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);
        }
예제 #2
0
파일: Sqlite.cs 프로젝트: aata/szotar
        /// <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);
        }