Example #1
0
        private void LoadDictionary(FileInfo dictionaryFile)
        {
            XDocument xDoc = XDocument.Load(dictionaryFile.FullName);

            foreach (XElement categoryElement in xDoc.Root.Element("Expense").Descendants("Category"))
            {
                CategoryMap category = LoadCategoryMap(categoryElement);

                this.expenseCategories.Add(category);
            }

            foreach (XElement categoryElement in xDoc.Root.Element("Income").Descendants("Category"))
            {
                CategoryMap category = LoadCategoryMap(categoryElement);

                this.incomeCategories.Add(category);
            }
        }
Example #2
0
        private static CategoryMap LoadCategoryMap(XElement categoryElement)
        {
            CategoryMap category = new CategoryMap()
            {
                Name = categoryElement.Attribute("Name").Value
            };


            List <string> allDirectTokens = LoadTokensFromElement(categoryElement);

            category.MapFrom = new List <string>(allDirectTokens);

            foreach (XElement subcategoryElement in categoryElement.Elements("Subcategory"))
            {
                SubcategoryMap subcategory = new SubcategoryMap();
                subcategory.Name    = subcategoryElement.Attribute("Name").Value;
                subcategory.MapFrom = LoadTokensFromElement(subcategoryElement);
                category.Subcategories.Add(subcategory);
            }

            return(category);
        }