private void ProcessOption(MainViewModel model, Dictionary<string, AreaOption> areas, Category shellCategory, Category shellSubCategory, OptionBaseType option) { if (option is UIOptionType) { var uiOption = option as UIOptionType; if (!ShouldOptionBeVisible(uiOption, model.AppModel.IsAdmin)) { return; } var shellOption = CreateShellOption(shellSubCategory, uiOption); if (shellOption != null) { shellOption.IsEnabled = ShouldOptionBeEnabled(uiOption, model.AppModel.IsAdmin); shellOption.Category = shellCategory; shellOption.SubCategory = shellSubCategory; if (!string.IsNullOrEmpty(uiOption.Area)) { if (!areas.ContainsKey(uiOption.Area)) { var area = new AreaOption { Name = uiOption.Area, DisplayName = uiOption.DisplayText, Description = uiOption.DisplayText, Category = shellCategory, SubCategory = shellSubCategory }; areas.Add(uiOption.Area, area); } areas[uiOption.Area].AddSubOption(shellOption, uiOption.PolicyScope); } else { model.AddOption(shellOption); } } } else if (option is UIOptionGroupType) { shellSubCategory.ContainsInstances = true; var optionGroup = option as UIOptionGroupType; foreach (var instance in optionGroup.OptionGroupInstances) { model.AddOption(CreateShellOptionGroupInstance(shellSubCategory, instance)); } } }
/// <summary> /// Map Workshare.Option.ObjectModel to WCM UI data model. /// </summary> /// <param name = "model">UI data model to be changed</param> /// <param name = "optionsRoot">Option object model to convert from</param> /// <param name = "bAdmin">Switch Admin / User mode</param> private void OptionModelToUIModel(MainViewModel model) { var areas = new Dictionary<string, AreaOption>(); model.Options.Clear(); model.Categories.Clear(); foreach (var category in _optionsRoot.Categories) { ProcessCategory(model, areas, category); } foreach (var item in areas) { model.AddOption(item.Value); } foreach (Category cat in model.Categories) { cat.SubCategories.Sort(item => item.Order); } model.BuildCompositeOptions(); }
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); } } }