public LemmaRepository(LemmaDatabase db, string tableName, string[] columnNames)
        {
            Database   = db;
            TableName  = tableName;
            ColumNames = columnNames;

            InsertCmd = db.CreateCommand("insert into " + TableName + "(word," + string.Join(",", columnNames)
                                         + ") values(@word, @" + string.Join(", @", columnNames) + ")");
            InsertCmd.Prepare();
            string[] columnSetters = columnNames.Select(x => x + "=@" + x).ToArray(); // x=@x
            UpdateCmd = db.CreateCommand("update " + TableName + " set word=@word, " + string.Join(", ", columnSetters) + " where id=@id");
            UpdateCmd.Prepare();
            DeleteCmd = db.CreateCommand("delete from " + TableName + " where id=@id");
            DeleteCmd.Prepare();
            CountCmd = db.CreateCommand("select count(*) from " + TableName);
            CountCmd.Prepare();
            SelectByIdCmd = db.CreateCommand("select * from " + TableName + " where id=@id");
            SelectByIdCmd.Prepare();
            SelectPageOfDataCmd = db.CreateCommand("select * from " + TableName + " limit @pageSize offset @offset");
            SelectPageOfDataCmd.Prepare();
        }
Beispiel #2
0
 private void LoadDatabase(string fileName)
 {
     updateDatabase = false;
     if(db != null) {
         db.CloseDatabase();
     }
     if(fileName == null) {
         db = LemmaDatabase.CreateDefaultInstance();
     } else {
         db = new LemmaDatabase(fileName);
     }
     db.OpenChangeSet();
     nounRepo = new NounRepository(db);
     prepRepo = new PrepositionRepository(db);
     RefreshGridView();
     updateDatabase = true;
 }
Beispiel #3
0
 public NounRepository(LemmaDatabase db) : base(db, "lemma", new string[] { "gender" })
 {
 }
Beispiel #4
0
        private void ThisAddIn_Startup(object sender, EventArgs e)
        {
            db = LemmaDatabase.CreateDefaultInstance();
            repo = new NounRepository(db);

            instantLookup = new InstantLookup<MSWord.Document>(new WordActiveTextStrategy(Application), 250, repo);
            instantLookup.OnLemmaFound += InstantLookup_OnLemmaFound;

            if (taskPaneVisible)
            {
                AddAllTaskPanes();
            }
            ((MSWord.ApplicationEvents4_Event)Application).NewDocument += ThisAddIn_NewDocument;
            Application.DocumentOpen += Application_DocumentOpen;
            Application.DocumentChange += Application_DocumentChange;

            ToggleInstantLookup(this, instantLookupEnabled, null);
        }
 public PrepositionRepository(LemmaDatabase db) : base(db, "preposition", new string[] { "wordCase" })
 {
 }