예제 #1
0
        /// <summary>
        /// Initializes the context and loads necessary data into memory through the configured database adapter.
        /// This must be done before the context is usable.
        /// </summary>
        public virtual void Initialize()
        {
            if (Adapter == null)
            {
                throw new InvalidConfigurationException("DBContext requires a configured database adapter.  Please check your configuration.");
            }

            // Initiaze NHibernate session
            Adapter.Initialize(this);

            new Thread(delegate()
            {
                using (InitLock.WriteLock())
                {
                    // Initialize ingredient parser
                    ingParser           = new IngredientParser();
                    var ingredientIndex = Adapter.LoadIngredientsForIndex();
                    ingParser.CreateIndex(ingredientIndex);

                    // Initialize modeler
                    modeler = new ModelerProxy(this);
                    modeler.LoadSnapshot();

                    // Initialize natural language parsing
                    IngredientSynonyms.InitIndex(Adapter.IngredientLoader);
                    UnitSynonyms.InitIndex(Adapter.UnitLoader);
                    FormSynonyms.InitIndex(Adapter.FormLoader);
                    PrepNotes.InitIndex(Adapter.PrepLoader);
                    Anomalies.InitIndex(Adapter.AnomalyLoader);
                    NumericVocab.InitIndex();

                    parser = new Parser();
                    LoadTemplates();
                }
            }).Start();

            Thread.Sleep(500); // Provides time for initialize thread to start and acquire InitLock
        }
예제 #2
0
 public void Initialize()
 {
     ModelerProxy = new ModelerProxy(this);
     ModelerProxy.LoadSnapshot();
 }