예제 #1
0
 public void Assign(IRecipe recipe)
 {
     Id = recipe.Id;
     Name = recipe.Name + "\n" + getIngredientList();
     Text = recipe.Text;
     Date = recipe.Date;
 }
예제 #2
0
        public void Show(IRecipe recipe)
        {
            Console.Clear();
            Header = recipe.Name;
            ShowHeaderPanel();

            Console.WriteLine("\nIngredienser");
            Console.WriteLine("=============");

            foreach (Ingredient ingredient in recipe.Ingredients)
            {
                Console.WriteLine(ingredient);
            }

            int instructionCount = 1;

            Console.WriteLine("\nGör så här");
            Console.WriteLine("============");
            foreach (string instructions in recipe.Instructions)
            {
                Console.WriteLine("<{0}>", instructionCount);
                Console.WriteLine(instructions);
                instructionCount++;
                Console.WriteLine();
            }
        }
        public IRecipe SaveRecipe(string filename, IRecipe recipe)
        {
            if (recipe == null)
            throw new ArgumentNullException ("recipe");

             return SaveRecipeCore (filename, recipe);
        }
예제 #4
0
 public Garlic(IRecipe inRecipe, double inUnits)
 {
     this.setRecipe(inRecipe);
     this.Units = inUnits;
     this.IsOrganic = true;
     this.UnitPrice = DEFAULT_UNIT_COST;
 }
예제 #5
0
 public Salt(IRecipe inRecipe, double inUnits)
 {
     this.setRecipe(inRecipe);
     this.Units = inUnits;
     this.IsOrganic = false;
     this.UnitPrice = DEFAULT_UNIT_COST;
 }
예제 #6
0
    public void NullRecipeThrowsNullException()
    {
        IRecipe recipe = null;

        //Assert
        Assert.Throws <NullReferenceException>(() => sut.AddRecipeItem(recipe));
    }
예제 #7
0
        /// <summary>
        /// Adds the meal record.
        /// </summary>
        /// <param name="item">The meal history record.</param>
        /// <returns></returns>
        public async Task <IRecipe> AddRecipe(IRecipe item)
        {
            var wrappedRecord = item as Recipe;
            var newMealRecord = wrappedRecord != null?wrappedRecord.UnwrapDataObject() : item;

            if (newMealRecord != null)
            {
                using (var dietyContext = DietyDbContext)
                {
                    //newMealRecord as RecipeDb
                    //var newItem = new RecipeDb
                    //{
                    //	ComponentsList = newMealRecord.ComponentsList,
                    //	Description = newMealRecord.Description,
                    //	Name = newMealRecord.Name,
                    //	Id = newMealRecord.Id,
                    //	MealType = newMealRecord.MealType
                    //};
                    dietyContext.Recipes.Add(newMealRecord as RecipeDb);
                    await dietyContext.SaveChangesAsync();
                }
                await Task.Yield();
            }
            return(item);
        }
예제 #8
0
        public double ApplyToRecipe(IRecipe targetRecipe)
        {
            var og        = targetRecipe.GetEstimatedOriginalGravity();
            var forReturn = ((og - 1) - ((og - 1) * this.Attenuation / 100)) + 1;

            return(forReturn);
        }
예제 #9
0
        public void ApplyBitterToRecipe()
        {
            RecipeFactory     myFactory           = new RecipeFactory();
            IRecipe           myRecipe            = myFactory.GetRecipe(RecipeTypes.Beer);
            IngredientFactory myIngredientFactory = new IngredientFactory();
            var ingredient = myIngredientFactory.GetIngredient(IngredientType.Fermentable);

            ingredient.Amount = 10;
            (ingredient as IFermentable).DiastaticPower = 1.04;
            myRecipe.Ingredients.Add(ingredient);
            //adding bitters is just a test for my sanity in querying interfaces and dealing with Covariance
            //note it will be repeated on the IBU calculation as the fermentable power impacts bitterness
            ingredient        = myIngredientFactory.GetIngredient(IngredientType.BitterSeason);
            ingredient.Amount = 1.5;
            (ingredient as IBitter).BitteringFactor       = 15;
            (ingredient as IBitter).BitterCalculationTime = 60;
            myRecipe.Ingredients.Add(ingredient);
            myRecipe.BatchVolume            = 6.5;
            myRecipe.TotalEfficiencyPercent = 70;
            var ibus = myRecipe.GetEstimatedBitterness();

            Assert.AreEqual(myRecipe.Bitters.Count, 1);
            //May need to check formula.  BeerSmith usually is a little higher.  BeerSmith has been known to tweak their forumulas though.
            Assert.AreEqual(63.81, Math.Round(ibus, 2));
        }
예제 #10
0
 public void SetUp()
 {
     Inventory = new Inventory(InventoryJSON);
     Recipe    = new Recipe(RecipesJSON);
     Logger    = new Mock <ILogger>();
     Factory   = new AutoFactory(Inventory, Recipe, Logger.Object);
 }
예제 #11
0
        public void CraftButton()
        {
            if (this.CraftingItemContainer.CanCraft())
            {
                foreach (IItemInstance item in this.CraftingItemContainer.Contents)
                {
                    this.Player.AddContents(item.Contents);
                }

                this.Player.RemoveContents(this.CraftingItemContainer.Contents);

                List <IItemInstance> newItems = new List <IItemInstance>();
                IRecipe recipe = this.CraftingItemContainer.InferRecipeFromIngredients();
                if (recipe is null)
                {
                    return;
                }

                foreach (BaseItemType itemType in recipe.CraftingResults)
                {
                    IItemInstance item = this.ItemFactory.CreateFromTemplate(
                        itemType,
                        true);
                    newItems.Add(item);
                    GlobalConstants.GameManager.ItemHandler.Add(item);
                }

                this.Player.AddContents(newItems);

                this.PlayerInventory.Display();

                this.CraftingItemContainer.RemoveAllItems();
            }
        }
예제 #12
0
파일: DbRecipe.cs 프로젝트: m1sha/GitHubSvn
 public void Assign(IRecipe recipe)
 {
     Id = recipe.Id;
     Name = recipe.Name;
     Text = recipe.Text;
     Date = recipe.Date;
 }
 public void AddRecipe(IRecipe recipe)
 {
     if(recipe == null)
     {
         throw new ArgumentNullException("Recipe cannot be null");
     }
     this.recipes.Add(recipe);
 }
예제 #14
0
        public void AddRecipe(IRecipe recipe)
        {
            if (recipe == null)
            {
                throw new ArgumentNullException("Recipe you try to add in restaurant recipes cannot be null");
            }

            this.recipes.Add(recipe);
        }
예제 #15
0
 public Batch(string brewerName, IRecipe recipe)
 {
     m_brewerName = brewerName;
     m_recipe = recipe;
     m_assistantBrewerName = null;
     m_originalGravity = null;
     m_finalGravity = null;
     m_recordedGravityReadings = new ObservableCollection<IGravityReading>();
 }
예제 #16
0
        public void AddRecipe(IRecipe recipe)
        {
            bool isDuplicate = this.Recipes.Any(x => x.Name == recipe.Name);

            if (isDuplicate)
            {
                throw new InvalidOperationException();
            }

            this.Recipes.Add(recipe);
        }
예제 #17
0
        public float TestRecipe(IRecipe recipe)
        {
            float result = 0.0f;
            var sp = new RecipeGroups (recipe.GetGroups ());

            foreach (var permutation in _resultPermutations) {
                var match = sp.TestMatch (permutation);
                if (match > 0) {
                    result = Math.Max (result, match);
                }
            }

            return result;
        }
예제 #18
0
      public DefaultXmlWriter(IRecipe recipe, string resultsPathFileName) {
         if( resultsPathFileName != string.Empty ) {
            _resultsFileName = resultsPathFileName;
         }
         _recipeStarted = OnRecipeStarted;
         _recipeFinished = OnRecipeFinished;
         _assemblyStarted = OnAssemblyStarted;
         _assemblyFinished = OnAssemblyFinished;

         _testPassed = OnTestPassed;
         _testFailed = OnTestFailed;
         _testError = OnTestError;
         _testSkipped = OnTestSkipped;
         Hookup(recipe);
      }
예제 #19
0
 public int compareRecipes(IRecipe irecipe, IRecipe irecipe1)
 {
     if ((irecipe is ShapelessRecipes) && (irecipe1 is ShapedRecipes))
     {
         return 1;
     }
     if ((irecipe1 is ShapelessRecipes) && (irecipe is ShapedRecipes))
     {
         return -1;
     }
     if (irecipe1.getRecipeSize() < irecipe.getRecipeSize())
     {
         return -1;
     }
     return irecipe1.getRecipeSize() <= irecipe.getRecipeSize() ? 0 : 1;
 }
예제 #20
0
      private void Hookup(IRecipe recipe) {
         _document = XmlDocumentFactory.CreateInstance();

         WriteDocumentHeader(recipe.DisplayName);

         recipe.Started  += _recipeStarted;
         recipe.Finished += _recipeFinished;
         recipe.Aborted += _recipeFinished;

         foreach(var ta in recipe.Assemblies) {
            ta.AssemblyStarted  += _assemblyStarted;
            ta.AssemblyFinished += _assemblyFinished;

            ta.TestPassed  += _testPassed;
            ta.TestFailed  += _testFailed;
            ta.TestError   += _testError;
            ta.TestSkipped += _testSkipped;
         }
      }
예제 #21
0
파일: RecipeView.cs 프로젝트: rn222cx/WP14
 public void Show(IRecipe recipe)
 {
     Header = recipe.Name; //tilldela receptens namn i headern
     ShowHeaderPanel(); // visa headern
     Console.WriteLine("\nIngridienser\n===================");
     //Skriver ut ingridienserna med en radbrytning
     foreach (IIngredient ingridient in recipe.Ingredients)
     {
         Console.WriteLine(ingridient);
     }
     int count = 1;
     Console.WriteLine("\nGör så här\n===================");
     //skriver ut instruktioner samt nummrering som ökas varje gång
     foreach (string instruction in recipe.Instructions)
     {
         Console.WriteLine("<{0}>", count++);
         Console.WriteLine("{0}\n", instruction);
     }
 }
        public void ExecuteRecipe(IRecipe recipe)
        {
            if (_shellSettings.Name == recipe.TenantName)
            {
                _importExportServiceWork.Value.Import(recipe.RecipeText);
            }
            else
            {
                var shellContext = _orchardHost.GetShellContext(new ShellSettings { Name = recipe.TenantName });

                if (shellContext == null || shellContext.Settings.State != TenantState.Running)
                {
                    throw new InvalidOperationException("There is no tenant running with the name \"" + recipe.TenantName + "\".");
                }

                var shellSettings = shellContext.Settings;
                IWorkContextScope environment;
                using (environment = shellContext.LifetimeScope.Resolve<IWorkContextAccessor>().CreateWorkContextScope())
                {
                    IImportExportService importExportService;
                    if (!environment.TryResolve<IImportExportService>(out importExportService))
                    {
                        IFeatureManager featureManager;
                        if (!environment.TryResolve<IFeatureManager>(out featureManager))
                        {
                            throw new InvalidOperationException("The tenant \"" + recipe.TenantName + "\" is not running properly.");
                        }

                        featureManager.EnableFeatures(new[] { "Orchard.ImportExport" }, true);

                        // Reloading the shell. This is costly but unfortunately necessary, just creating a new work context isn't enough.
                        environment.Dispose();
                        environment = _orchardHost.CreateStandaloneEnvironment(shellSettings);

                        importExportService = environment.Resolve<IImportExportService>();
                    }

                    importExportService.Import(recipe.RecipeText);
                }
            }
        }
 public void Show(IRecipe recipe)
 {
     Console.Clear();
     int i = 0;
     Header = recipe.Name;
     ShowHeaderPanel();
     Console.WriteLine(Text_lines.ingredienser_prompt + Environment.NewLine +
         Text_lines.div_prompt);
     foreach (var ingredient in recipe.Ingredients)
     {
         Console.WriteLine(ingredient);
     }
     Console.WriteLine(Environment.NewLine + Text_lines.instruktioner_prompt +
         Environment.NewLine + Text_lines.div_prompt);
     foreach (var line in recipe.Instructions)
     {
         i++;
         Console.WriteLine("<{0}>" + Environment.NewLine + "{1}" +
             Environment.NewLine, i, line);
     }
 }
예제 #24
0
 public RecipeView(IRecipe recipe, IIngredient[] ingredient)
 {
     Assign(recipe);
     Ingredients = new IngredientCollectionView(ingredient);
 }
 public void RemoveRecipe(IRecipe recipe)
 {
     if (this.Recipes.Contains(recipe))
     {
         this.Recipes.Remove(recipe);
     }
 }
예제 #26
0
파일: DbRecipe.cs 프로젝트: m1sha/GitHubSvn
 public DbRecipe(IRecipe recipe)
 {
     Assign(recipe);
 }
예제 #27
0
 private static void SetUpRegexSelector(CmdLineHandler clh, IRecipe recipe) {
    if(clh.HasOption("pattern")) {
       var selector = new RegexSelector {  
          Pattern = clh.GetOptionValueFor( "pattern" )
       };
       recipe.RegisterSelector(selector);
    }
 }
예제 #28
0
        public void RemoveRecipe(IRecipe recipe)
        {
            if (recipe == null)
            {
                throw new ArgumentNullException("Recipe you try to remove in restaurant recipes cannot be null");
            }

            this.recipes.Remove(recipe);
        }
예제 #29
0
 public void AddRecipe(IRecipe recipe)
 {
     this.ValidationForNull(recipe, ValueCanTBeNull);
     this.recipes.Add(recipe);
 }
예제 #30
0
 public void RemoveRecipe(IRecipe recipe)
 {
     this.ValidationForNull(recipe, ValueCanTBeNull);
     this.recipes.Remove(recipe);
 }
예제 #31
0
 protected void setRecipe(IRecipe newRecipe)
 {
     this.Recipe = newRecipe;
 }
 /// <summary>
 /// Deletes a recipe.
 /// </summary>
 /// <param name="recipe">The recipe to delete. The value can be null.</param>
 public virtual void Delete(IRecipe recipe)
 {
     // If it's a copy of a recipe...
     if (!_recipes.Contains(recipe))
     {
         // ...try to find the original!
         recipe = _recipes.Find(r => r.Equals(recipe));
     }
     _recipes.Remove(recipe);
     IsModified = true;
     OnRecipesChanged(EventArgs.Empty);
 }
예제 #33
0
 public void AddRecipe(IRecipe recipe)
 {
     this.Recipes.Add(recipe);
 }
예제 #34
0
 public void addFavorite(IRecipe aRecipe)
 {
     myFaves.Add(aRecipe);
     updateView();
 }
예제 #35
0
 public void removeFavourite(IRecipe aRecipe)
 {
     myFaves.Remove(aRecipe);
     updateView();
 }
예제 #36
0
 public void RemoveRecipe(IRecipe recipe)
 {
     this.Recipes.Remove(recipe);
 }
예제 #37
0
        public IRecipe SaveRecipe(string filename, IRecipe recipe)
        {
            var formatter = new XmlFormatter ();

             Meal.Svc.Persistance.Recipe r = recipe as Meal.Svc.Persistance.Recipe ?? Meal.Svc.Persistance.Recipe.FromRecipe (recipe);

             using (var stream = System.IO.File.Create (filename))
             {
            //XamlWriter.Save (r, stream);

            formatter.Serialize (stream, r);
            stream.Close ();
             }
             return recipe;
        }