Пример #1
0
        private void ParseCategories(IEnumerable <XElement> categories)
        {
            Category category;

            foreach (var categoryIterator in categories)
            {
                var    questions    = categoryIterator.Descendants("question");
                string categoryId   = categoryIterator.Attribute("id").Value;
                string categoryName = categoryIterator.Attribute("name").Value;
                if (categoryIterator.Attribute("condition") != null)
                {
                    ConditionCategory condintionalCategoryInstance = new ConditionCategory(this)
                    {
                        Id = categoryId, Name = categoryName
                    };
                    condintionalCategoryInstance.ConditionQuestion = categoryIterator.Attribute("condition").Value;
                    foreach (var questionIterator in questions)
                    {
                        ParseQuestion(questionIterator, condintionalCategoryInstance.QuestionsTemplate, condintionalCategoryInstance);
                    }
                    category = condintionalCategoryInstance;
                }
                else
                {
                    NormalCategory normalCategoryInstance = new NormalCategory(this)
                    {
                        Id = categoryId, Name = categoryName
                    };

                    foreach (var questionIterator in questions)
                    {
                        ParseQuestion(questionIterator, normalCategoryInstance.Questions, normalCategoryInstance);
                    }
                    category = normalCategoryInstance;
                }
                Categories.Add(category);
            }
        }
Пример #2
0
        private void ParseCategories(IEnumerable<XElement> categories)
        {
            Category category;
            foreach (var categoryIterator in categories)
            {
                var questions = categoryIterator.Descendants("question");
                string categoryId = categoryIterator.Attribute("id").Value;
                string categoryName = categoryIterator.Attribute("name").Value;
                if (categoryIterator.Attribute("condition") != null)
                {
                    ConditionCategory condintionalCategoryInstance = new ConditionCategory(this) { Id = categoryId, Name = categoryName };
                    condintionalCategoryInstance.ConditionQuestion = categoryIterator.Attribute("condition").Value;
                    foreach (var questionIterator in questions)
                    {
                        ParseQuestion(questionIterator, condintionalCategoryInstance.QuestionsTemplate, condintionalCategoryInstance);
                    }
                    category = condintionalCategoryInstance;
                }
                else
                {
                    NormalCategory normalCategoryInstance = new NormalCategory(this) { Id = categoryId, Name = categoryName };

                    foreach (var questionIterator in questions)
                    {
                        ParseQuestion(questionIterator, normalCategoryInstance.Questions, normalCategoryInstance);
                    }
                    category = normalCategoryInstance;
                }
                Categories.Add(category);
            }
        }