本文整理汇总了C#中MainViewModel.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# MainViewModel.Clear方法的具体用法?C# MainViewModel.Clear怎么用?C# MainViewModel.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MainViewModel
的用法示例。
在下文中一共展示了MainViewModel.Clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildModel
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;
}