public static void LoadWSOFile(string filePath, MainViewModel viewModel)
		{
			// Load user's current options and make a copy.
			BuildModel(viewModel, false);

			IVisitorWithContext visitor = new XmlReadVisitor();
			UIOptionRootType optionsRoot = new UIOptionRootType();
			optionsRoot.Accept(visitor, filePath);

			foreach (var cat in optionsRoot.Categories)
			{
				foreach (var subCat in cat.SubCategories)
				{
					foreach (var opt in subCat.Options)
					{
						if (opt is UIOptionGroupType)
						{
							LoadGroup(viewModel, opt);
						}
						IOption targetOpt = viewModel.FindOption(opt.Name);
						if (targetOpt != null)
						{
							LoadOption(targetOpt, opt);
						}
					}
				}
			}

			// We need to pass the OptionsRoot object to somebody who can display it in UI
		}
Example #2
0
		public void TestXmlReader()
		{
			IVisitorWithContext readVisitor = new XmlReadVisitor();
			UIOptionRootType optionsRoot = new UIOptionRootType();
			optionsRoot.Accept(readVisitor, _xmlInputPath);

			Assert.AreEqual(3, optionsRoot.Categories.Count);
			Assert.AreEqual(3, optionsRoot.Categories[0].SubCategories.Count);
			Assert.AreEqual(3, optionsRoot.Categories[1].SubCategories.Count);
			Assert.AreEqual(3, optionsRoot.Categories[2].SubCategories.Count);

			Assert.AreEqual(24, optionsRoot.Categories[0].SubCategories[0].Options.Count);
			Assert.AreEqual(2, optionsRoot.Categories[0].SubCategories[1].Options.Count);
			Assert.AreEqual(2, optionsRoot.Categories[0].SubCategories[2].Options.Count);
			Assert.AreEqual(2, optionsRoot.Categories[1].SubCategories[0].Options.Count);
			Assert.AreEqual(3, optionsRoot.Categories[1].SubCategories[1].Options.Count);
			Assert.AreEqual(2, optionsRoot.Categories[1].SubCategories[2].Options.Count);
			Assert.AreEqual(2, optionsRoot.Categories[2].SubCategories[0].Options.Count);
			Assert.AreEqual(2, optionsRoot.Categories[2].SubCategories[1].Options.Count);
			Assert.AreEqual(4, optionsRoot.Categories[2].SubCategories[2].Options.Count);
		}