示例#1
0
文件: TypeCache.cs 项目: liaoyu45/LY
 internal TypeCache(Type dbType, IDbLoader loader, Func <MainTableData[]> getTables)
 {
     BaseDbContextName = dbType.FullName;
     while (dbType.BaseType != null)
     {
         assemblies.Add(dbType.Assembly.Location);
         dbType = dbType.BaseType;
     }
     this.loader = loader;
     loadTables  = getTables;
 }
        public void LoadTrainingData(IDbLoader loader)
        {
            this.trainingData = new Dictionary<Guid, IRecipeClassification>();

            this.breakfastIndex = new RecipeIndex();
            this.lunchIndex = new RecipeIndex();
            this.dinnerIndex = new RecipeIndex();
            this.dessertIndex = new RecipeIndex();

            var data = loader.LoadTrainingData();

            foreach (var recipe in data)
            {
                this.trainingData.Add(recipe.Recipe.Id, recipe);

                if (recipe.IsBreakfast)
                {
                    this.breakfastIndex.Add(recipe.Recipe);
                }

                if (recipe.IsLunch)
                {
                    this.lunchIndex.Add(recipe.Recipe);
                }

                if (recipe.IsDinner)
                {
                    this.dinnerIndex.Add(recipe.Recipe);
                }

                if (recipe.IsDessert)
                {
                    this.dessertIndex.Add(recipe.Recipe);
                }
            }
        }