本文整理汇总了C#中IViewModelFactory.CreateViewModel方法的典型用法代码示例。如果您正苦于以下问题:C# IViewModelFactory.CreateViewModel方法的具体用法?C# IViewModelFactory.CreateViewModel怎么用?C# IViewModelFactory.CreateViewModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IViewModelFactory
的用法示例。
在下文中一共展示了IViewModelFactory.CreateViewModel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddActionViewModels
public static List<ActionViewModel> AddActionViewModels(IList cmds, IDataObject obj, IEnumerable<Method> methods, ViewModel parent, IViewModelFactory vmdlFactory)
{
var result = new List<ActionViewModel>();
var ctx = obj.Context;
methods
.SelectMany(m => (String.IsNullOrEmpty(m.CategoryTags) ? "Summary" : m.CategoryTags)
.Split(", ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
.Select(s => new { Category = s == "Summary" ? string.Empty : s, Method = m })) // make summary empty -> will be first, then groups
.GroupBy(x => x.Category, x => x.Method)
.OrderBy(group => group.Key)
.ForEach(group =>
{
var name = group.Key;
if (string.IsNullOrEmpty(name))
{
foreach (var m in group.OrderBy(m => m.Name))
{
var mdl = vmdlFactory.CreateViewModel<ActionViewModel.Factory>(m).Invoke(ctx, parent, obj, m);
cmds.Add(mdl);
result.Add(mdl);
}
}
else
{
var mdls = group.OrderBy(m => m.Name).Select(m => vmdlFactory.CreateViewModel<ActionViewModel.Factory>(m).Invoke(ctx, parent, obj, m)).ToArray();
result.AddRange(mdls);
var container = vmdlFactory
.CreateViewModel<ContainerCommand.Factory>()
.Invoke(
ctx,
parent,
name,
"",
mdls);
cmds.Add(container);
}
});
return result;
}
示例2: Fetch
public static FilterListEntryViewModel Fetch(IViewModelFactory f, IZetboxContext dataCtx, FilterListViewModel parent, FilterViewModel vmdl)
{
return (FilterListEntryViewModel)dataCtx.GetViewModelCache(f.PerfCounter).LookupOrCreate(vmdl, () => f.CreateViewModel<FilterListEntryViewModel.Factory>().Invoke(dataCtx, parent, vmdl));
}
示例3: Fetch
public static CompoundObjectViewModel Fetch(IViewModelFactory f, IZetboxContext dataCtx, ViewModel parent, ICompoundObject obj)
{
return (CompoundObjectViewModel)dataCtx.GetViewModelCache(f.PerfCounter).LookupOrCreate(obj, () => f.CreateViewModel<CompoundObjectViewModel.Factory>(obj).Invoke(dataCtx, parent, obj));
}
示例4: Fetch
public static NavigationEntryViewModel Fetch(IViewModelFactory ModelFactory, IZetboxContext dataCtx, ViewModel parent, NavigationEntry screen)
{
if (ModelFactory == null) throw new ArgumentNullException("ModelFactory");
if (screen == null) throw new ArgumentNullException("screen");
return (NavigationEntryViewModel)dataCtx.GetViewModelCache(ModelFactory.PerfCounter).LookupOrCreate(screen, () =>
{
if (screen.ViewModelDescriptor != null)
{
try
{
var t = Type.GetType(screen.ViewModelDescriptor.ViewModelTypeRef, true);
return ModelFactory.CreateViewModel<NavigationEntryViewModel.Factory>(t).Invoke(dataCtx, parent, screen);
}
catch (Exception ex)
{
Logging.Client.WarnFormat("Unable to create ViewModel from Descriptor: {0}", ex);
}
}
return (NavigationEntryViewModel)screen.GetDefaultViewModel(dataCtx, parent);
});
}
示例5: Fetch
public static FilterViewModel Fetch(IViewModelFactory f, IZetboxContext dataCtx, ViewModel parent, IUIFilterModel mdl)
{
return (FilterViewModel)dataCtx.GetViewModelCache(f.PerfCounter).LookupOrCreate(mdl, () => f.CreateViewModel<FilterViewModel.Factory>(mdl.ViewModelType).Invoke(dataCtx, parent, mdl));
}