Esempio n. 1
0
        private CategoryXml GetCategory(string name)
        {
            System.Diagnostics.Debug.Assert(_Database != null);

            if (_Database.Categories == null)
            {
                _Database.Categories    = new CategoryXml[1];
                _Database.Categories[0] = new CategoryXml(name);
                return(_Database.Categories[0]);
            }

            foreach (CategoryXml category in _Database.Categories)
            {
                if (category.Name == name)
                {
                    return(category);
                }
            }

            CategoryXml appendedCategory = new CategoryXml(name);

            CategoryXml[] categories = new CategoryXml[_Database.Categories.Length + 1];
            categories[categories.Length - 1] = appendedCategory;
            _Database.Categories.CopyTo(categories, 0);
            _Database.Categories = categories;

            return(appendedCategory);
        }
Esempio n. 2
0
        private ExerciseXml GetExercise(string categoryName, string exerciseName)
        {
            CategoryXml category = GetCategory(categoryName);

            if (category.Exercises == null)
            {
                category.Exercises    = new ExerciseXml[1];
                category.Exercises[0] = new ExerciseXml(exerciseName);
                return(category.Exercises[0]);
            }

            foreach (ExerciseXml exercise in category.Exercises)
            {
                if (exercise.Name == exerciseName)
                {
                    return(exercise);
                }
            }

            ExerciseXml appendedExercise = new ExerciseXml(exerciseName);

            ExerciseXml[] exercises = new ExerciseXml[category.Exercises.Length + 1];
            exercises[exercises.Length - 1] = appendedExercise;
            category.Exercises.CopyTo(exercises, 0);
            category.Exercises = exercises;

            return(appendedExercise);
        }