예제 #1
0
		void IVisitor.Visit(UIOptionSubCategoryType subCategory)
		{
			string optionLocation = GetOptionKeyName(this._catergoryName, subCategory.Name);

			this._regFileWriter.WriteSubKey(optionLocation);
			foreach (OptionBaseType option in subCategory.Options)
			{
				if ((option.ReadCurrentUser && _localRegistryTarget == RegistryTargetEnum.HKCU) ||
					(option.ReadLocalMachine && _localRegistryTarget == RegistryTargetEnum.HKLM))
				{
					option.Accept(this);
				}
			}

			// Write out ignored user overrides
			if (this._localRegistryTarget == RegistryTargetEnum.HKLM)
			{
				var hklmOptions = (from opt in subCategory.Options
				                  where !opt.IsOverrideAllowed && opt.ReadCurrentUser
				                  select opt);
                if (hklmOptions.Any())
                {
                    this._regFileWriter.WriteSubKey(GetIgnoreHKCUValueKeyName());
                }

				foreach (var opt in hklmOptions)
				{
					_regFileWriter.WriteValue(opt.Name, "");
				}

				this._regFileWriter.EndSubkey();
			}

			this._regFileWriter.EndSubkey();
		}
예제 #2
0
		void IVisitorWithContext.Visit(UIOptionSubCategoryType subCategory, object context)
		{
			XmlNode subCategoryNode = (XmlNode) context;
			subCategory.Name = subCategoryNode.Name;
			subCategory.DisplayText = subCategoryNode.Attributes["DisplayText"].Value;			
			
			foreach (XmlNode node in subCategoryNode.ChildNodes)
			{
				// group nodes can only have one child if the child is just the template default, but the child will not be text
				// for all other nodes the single child will be text
				if (node.ChildNodes.Count > 1 || node.ChildNodes.Count == 1 && !(node.FirstChild is XmlText))	// Group Option Type
				{
					UIOptionGroupType groupOption = new UIOptionGroupType();
					subCategory.Options.Add(groupOption);

					groupOption.CategoryRef = subCategoryNode.ParentNode.Name;
					groupOption.SubCategoryRef = subCategoryNode.Name;
					groupOption.Accept(this, node);
				}
				else
				{
					UIOptionType option = new UIOptionType();					
					subCategory.Options.Add(option);

					option.CategoryRef = subCategoryNode.ParentNode.Name;
					option.SubCategoryRef = subCategoryNode.Name;
					option.Accept(this, node);
				}
			}
		}
예제 #3
0
		void IVisitor.Visit(UIOptionSubCategoryType subCategory)
		{
			foreach (OptionBaseType option in subCategory.Options)
			{
				option.Accept(this);
			}
		}
예제 #4
0
		void IVisitorWithContext.Visit(UIOptionSubCategoryType subCategory, object context)
		{
			XmlNode subCategoryNode = (XmlNode) context;
			XmlNode categoryNode = subCategoryNode.ParentNode;
			XmlNode rootNode = categoryNode.ParentNode;

			subCategory.Name = subCategoryNode.Attributes["ID"].Value;
			subCategory.DisplayText = subCategoryNode.Attributes["DisplayText"].Value;

			string xpath = "ws:Option[@SubCategoryRef='" + subCategory.Name + "']";
			XmlNamespaceManager nsmgr = new XmlNamespaceManager(rootNode.OwnerDocument.NameTable);
			nsmgr.AddNamespace("ws", "http://schemas.workshare.com/Workshare.OptionMap.xsd");
			XmlNodeList options = rootNode.SelectNodes(xpath, nsmgr);

			foreach (XmlNode node in options)
			{
				UIOptionType option = new UIOptionType();
				subCategory.Options.Add(option);
				option.Accept(this, node);
			}

			xpath = "ws:OptionGroupType[@SubCategoryRef='" + subCategory.Name + "']";
			options = rootNode.SelectNodes(xpath, nsmgr);

			foreach (XmlNode node in options)
			{
				UIOptionGroupType option = new UIOptionGroupType();
				subCategory.Options.Add(option);
				option.Accept(this, node);
			}
		}
예제 #5
0
		void IVisitorWithContext.Visit(UIOptionCategoryType category, object context)
		{
			XmlNode categoryNode = (XmlNode) context;

			category.Name = categoryNode.Attributes["ID"].Value;
			category.DisplayText = categoryNode.Attributes["DisplayText"].Value;

			foreach (XmlNode node in categoryNode.ChildNodes)
			{
				UIOptionSubCategoryType subCategory = new UIOptionSubCategoryType();
				category.SubCategories.Add(subCategory);
				subCategory.Accept(this, node);
			}			
		}
예제 #6
0
		void IVisitorWithContext.Visit(UIOptionSubCategoryType subCategory, object context)
		{
			XmlNode categoryNode = (XmlNode) context;
			XmlNode subCategoryNode = _xmlDoc.CreateNode(XmlNodeType.Element, subCategory.Name, this._namespaceURI);

			XmlAttribute displayText = _xmlDoc.CreateAttribute("DisplayText");
			displayText.Value = subCategory.DisplayText;
			subCategoryNode.Attributes.Append(displayText);

			foreach (OptionBaseType option in subCategory.Options)
			{
				option.Accept(this, subCategoryNode);
			}

			categoryNode.AppendChild(subCategoryNode);
		}
예제 #7
0
        internal void MergeDefaults(UIOptionSubCategoryType defaultSubCat)
        {
            foreach (OptionBaseType defaultOpt in defaultSubCat.Options)
            {
                OptionBaseType existingOpt = Options.Find(opt => defaultOpt.Name == opt.Name);
                if (existingOpt != null)
                {
            //        existingOpt.MergeDefaults(defaultOpt);
                }
                else
                {
                    Options.Add(defaultOpt);
                }
            }

            // remove all options we have loaded that aren't in the default options...
            Options.RemoveAll(opt => defaultSubCat.Options.Find(defopt => defopt.Name == opt.Name) == null);
        }
        public void Visit(UIOptionSubCategoryType subCategory, object context)
        {
			var vwSubCat = (Category)context;

            for (int i = subCategory.Options.Count - 1; i >= 0; i--)
            {
                if (subCategory.Options[i] is UIOptionGroupType)
                {
					// For UIOptionGroupType, we expect no default GroupInstance value is set, so always
					// add GroupInstance from ViewModel
					var grouptype = (UIOptionGroupType)subCategory.Options[i];
                    grouptype.OptionGroupInstances.Clear();

                    IEnumerable<OptionGroupInstance> vwGroupInsts = (from opt in vwSubCat.Options
                                                                     where opt is OptionGroupInstance
                                                                     select opt).Cast<OptionGroupInstance>();

					bool bAnyAdded;
					AddNewGroupInstance(grouptype, vwGroupInsts, out bAnyAdded);
					if (!bAnyAdded && _bTrimUnchanged)
                    {
						subCategory.Options.RemoveAt(i);
                    }
                }
                else
                {
                    IOption vwOpt = (from opt in vwSubCat.Options
                                     where opt.Name.Equals(subCategory.Options[i].Name, StringComparison.InvariantCultureIgnoreCase)
                                     select opt).FirstOrDefault();
                    if (vwOpt == null)
                        vwOpt = vwSubCat.FindOption(subCategory.Options[i].Name);
                    if (vwOpt == null)
                    {
						foreach (var opt in vwSubCat.Options)
						{
							AreaOption vwAreaOpt = opt as AreaOption;
							if (vwAreaOpt != null)
							{
								foreach (var vwAreaSubOpt in vwAreaOpt.SubOptions)
								{
									if (vwAreaSubOpt != null && vwAreaSubOpt.Name.Equals(subCategory.Options[i].Name, StringComparison.InvariantCultureIgnoreCase))
									{
										vwOpt = vwAreaSubOpt;
										break;
									}
								}
							}
							if (vwOpt != null)
							{
								break;
							}
						}
                    }

					if (!UpdateOptionIfChanged(subCategory.Options[i], vwOpt) && _bTrimUnchanged)
					{
							subCategory.Options.RemoveAt(i);
						}
					}
						}
					}
예제 #9
0
		internal void UpdateInternalSubCategory(MainViewModel model, UIOptionCategoryType category,
		                                        UIOptionSubCategoryType internalSubCategory)
		{
			var shellCategory = model.GetCategory(category.Name) ?? BuildShellCategory(category);
			shellCategory.Model = model;

			ProcessInternalOptions(model, internalSubCategory);
			return;
		}
예제 #10
0
		// This is used only to update the 'internal' sub category onto the viewModel with the internalSubCategory
		internal static void UpdateInternalSubCategory(MainViewModel viewModel, UIOptionRootType optionsRoot,
		                                               UIOptionSubCategoryType internalSubCategory)
		{
			if ((internalSubCategory == null) || (internalSubCategory.Name != "Internal"))
			{
				return;
			}

			OptionMapper mapper = new OptionMapper(optionsRoot);
			UIOptionCategoryType internalCat = optionsRoot.Categories.Find(cat => cat.Name == "Internal");
			mapper.UpdateInternalSubCategory(viewModel, internalCat, internalSubCategory);
		}
예제 #11
0
		private Category BuildShellSubCategory(Category shellCategory, UIOptionSubCategoryType subCategory)
		{
			Category shellSubCategory = new Category
			                            	{
			                            		DisplayName = subCategory.DisplayText,
			                            		Name = subCategory.Name,
			                            		Parent = shellCategory,
			                            		Order = GetOrderId(shellCategory.Name, subCategory.Name)
			                            	};
			return shellSubCategory;
		}
예제 #12
0
		private void ProcessSubCategory(MainViewModel model, Dictionary<string, AreaOption> areas, Category shellCategory,
		                                UIOptionSubCategoryType subCategory)
		{
			Category shellSubCategory = model.GetSubCategory(shellCategory.Name, subCategory.Name) ??
			                            BuildShellSubCategory(shellCategory, subCategory);
			shellSubCategory.Model = model;
			foreach (var option in subCategory.Options)
			{
				ProcessOption(model, areas, shellCategory, shellSubCategory, option);
			}
		}
예제 #13
0
		private void ProcessInternalOptions(MainViewModel model, UIOptionSubCategoryType subCategory)
		{
			var docProvs = subCategory.Options.Find(op => op.Name == "DocumentProviders") as UIOptionGroupType;
			var defaultDocProv = subCategory.Options.Find(op => op.Name == "DefaultDocumentProvider") as UIOptionType;

			StringOption defaultDocProvOpt = CreateShellOption(null, defaultDocProv) as StringOption;
			model.AddOption(defaultDocProvOpt);

			foreach (UIOptionGroupInstanceType instance in docProvs.OptionGroupInstances)
			{
				if (instance.Name == DefaultXmlReadVisitor.InstanceTemplateName)
				{
					continue;
				}

				if (instance.Name == "Offline Document Provider")
				{
					continue;
				}

				OptionGroupInstance shelloptiongroup = CreateShellOptionGroupInstance(null, instance);
				BoolOption enabledOpt =
					(from x in shelloptiongroup.SubOptions where x.Name == "Enabled" select x).FirstOrDefault() as BoolOption;
				model.AddOption(enabledOpt);

				if (IsFeatureEnabled(instance) || model.AppModel.IsAdmin)
				{
					DMSEnableOption newOpt = new DMSEnableOption(instance.Name, enabledOpt, defaultDocProvOpt)
					                         	{
					                         		Category = model.GetCategory("DMS"),
					                         		SubCategory = model.GetSubCategory("DMS", "General")
					                         	};

					newOpt.IsEnabled = ShouldOptionBeEnabled(newOpt, model.AppModel.IsAdmin);

					model.AddOption(newOpt);
				}
			}
		}
예제 #14
0
		public static MainViewModel BuildModel(MainViewModel model, bool loadAdminDefaults = false, bool loadFactoryDefaults = false, bool loadUserOptionsAsAdmin = false)
		{
			model.Clear();
			UIOptionRootType optionsRoot = OptionMapper.DefaultXmlToOptionModel();
			if (!loadFactoryDefaults)
			{
				bool isAdminModel = true;

				/*
				 * In the scenerio that we are in admin mode and we are loading user settings, 
				 * we need to pretend we're a normal user. So we check flag loadUserOptionsAsAdmin. 
				 */
				if (loadUserOptionsAsAdmin || !model.AppModel.IsAdmin)
					isAdminModel = false;

				OptionMapper.UpdateOptionModelWithCurrent(optionsRoot, isAdminModel || loadAdminDefaults);
			}

			if (!model.AppModel.IsAdmin)
			{
				// Filter out Categories ... based upon Enabled Features
				FilterCategories(optionsRoot);
			}

			OptionMapper.OptionModelToUIModel(model, optionsRoot);
			if (model.AppModel.IsAdmin)
			{
				// For Admin mode, we first load the 'current = XML + HKLM', and then the 'default = 'XML'.
				// Now, 'default' will not be having any info about the DocumentProviders as they are
				// defined as OptionGroupInstances (i.e., dynamic), and hence not a part of the XML.
				// So, when the 'current' is loaded, we cache the value of the DocumentProviders from
				// the 'internal' node, which is then used to 'update/dirty' up the 'default' model
				if (loadFactoryDefaults)
				{
					// Loading the 'default' model - 'update/dirty' with cached data for DocumentProviders
					OptionMapper.UpdateInternalSubCategory(model, optionsRoot, _internalSubCategory);
					_internalSubCategory = null;
				}
				else
				{
					// Loading the 'current' model - cache the value of the DocumentProviders
					UIOptionCategoryType internalCat = optionsRoot.Categories.Find(cat => cat.Name == "Internal");
					_internalSubCategory = internalCat.SubCategories.Find(cat => cat.Name == "Internal");
				}
			}

			return model;
		}
예제 #15
0
		private void WriteOptionGroups(UIOptionSubCategoryType subCategory)
		{
			var optionGroups = from opt in subCategory.Options
							   where (opt is UIOptionGroupType)
							   group opt by (opt as UIOptionGroupType) into optGroup
							   orderby optGroup.Key.ToString()
							   select new { OptionAreaName = optGroup.Key.ToString(), Options = optGroup };

			foreach (var optionGroup in optionGroups)
			{
				foreach (OptionBaseType option in optionGroup.Options)
				{
					if (!option.Private && 
						!option.RuntimeState &&
						((_localRegistryTarget == RegistryTargetEnum.HKCU && option.ReadCurrentUser) ||
						(_localRegistryTarget == RegistryTargetEnum.HKLM && option.ReadLocalMachine)))
					{
						option.Accept(this);
					}
				}

				WriteIgnoredUserOverrides(optionGroup.Options);
			}
		}
예제 #16
0
		void IVisitor.Visit(UIOptionSubCategoryType subCategory)
		{
			// Create SubCategory category
			_admFileWriter.StartCategory(subCategory.DisplayText);

			WriteScopedOptions(subCategory);
			WriteUnscopedOptions(subCategory);
			WriteOptionGroups(subCategory);

			_admFileWriter.EndCategory();
		}
예제 #17
0
		private void WriteScopedOptions(UIOptionSubCategoryType subCategory)
		{
			if (subCategory.Options.Any(opt => ((opt is UIOptionType) && (opt as UIOptionType).PolicyScopeSpecified == true)))
			{
				// First add all the 'PolicyScopeSpecified'
				var scopes = from opt in subCategory.Options
							 where (opt is UIOptionType) && (opt as UIOptionType).PolicyScopeSpecified == true
							 group opt by (opt as UIOptionType).PolicyScope into optGroup
							 orderby optGroup.Key.ToString()
							 select new { OptionScopeName = optGroup.Key.ToString(), Options = optGroup };

				foreach (var scope in scopes)
				{
					_admFileWriter.StartCategory(scope.OptionScopeName);
					foreach (OptionBaseType option in scope.Options)
					{
						if (!option.Private && 
							!option.RuntimeState &&
						    ((_localRegistryTarget == RegistryTargetEnum.HKCU && option.ReadCurrentUser) ||
							(_localRegistryTarget == RegistryTargetEnum.HKLM && option.ReadLocalMachine)))
						{
							option.Accept(this);
						}
					}
					WriteIgnoredUserOverrides(scope.Options);
					_admFileWriter.EndCategory();
				}
			}
		}
예제 #18
0
		private void WriteUnscopedOptions(UIOptionSubCategoryType subCategory)
		{
			var nonScopedAreas = from opt in subCategory.Options
								 where (opt is UIOptionType) && (opt as UIOptionType).PolicyScopeSpecified == false
								 group opt by (opt as UIOptionType).PolicyScope into optGroup
								 orderby optGroup.Key.ToString()
								 select new { OptionAreaName = optGroup.Key.ToString(), Options = optGroup };

			foreach (var nonScopedArea in nonScopedAreas)
			{
				foreach (OptionBaseType option in nonScopedArea.Options)
				{
					if (!option.Private && 
						!option.RuntimeState &&
						((_localRegistryTarget == RegistryTargetEnum.HKCU && option.ReadCurrentUser) ||
						(_localRegistryTarget == RegistryTargetEnum.HKLM && option.ReadLocalMachine)))
					{
						option.Accept(this);
					}
				}

				WriteIgnoredUserOverrides(nonScopedArea.Options);
			}
		}
예제 #19
0
 void IVisitor.Visit(UIOptionSubCategoryType subCategory)
 {
     throw new NotImplementedException();
 }
예제 #20
0
		private static int GetOptionIndexInSubCategory(UIOptionSubCategoryType subcat, string optionName)
		{
			int index = 0;
			foreach (OptionBaseType opt in subcat.Options)
			{
				if (opt.Name == optionName)
				{
					return index;
				}
				index++;
			}

			return -1;
		}