Beispiel #1
0
 private void ReadFile()
 {
     try
     {
         using (TextReader reader = new StreamReader(_ingredientFileName))
         {
             XmlSerializer deserializer = new XmlSerializer(typeof(GroupsList));
             object        obj          = deserializer.Deserialize(reader);
             _recipes = (GroupsList)obj;;
         }
     }
     catch
     {
         bool exists = System.IO.Directory.Exists(_directoryPath);
         if (!exists)
         {
             System.IO.Directory.CreateDirectory(_directoryPath);
         }
         if (File.Exists(_ingredientFileName))
         {
             File.Delete(_ingredientFileName);
         }
         CreateFile();
     }
 }
Beispiel #2
0
        private void CreateFile()
        {
            _recipes = new GroupsList();

            for (int i = 1; i <= GV.NB_GROUPS; i++)
            {
                Group gp = new Group();
                gp._groupID = i;
                _recipes._groupsList.Add(gp);
                for (int x = 1; x <= GV.NB_INGREDIENTS; x++)
                {
                    Ingredient ing = new Ingredient();
                    ing._ingredientID = x;
                    gp._ingredientList.Add(ing);
                }
            }
            Serialize();
        }