当前位置: 首页>>代码示例>>C#>>正文


C# IViewModelFactory.CreateViewModel方法代码示例

本文整理汇总了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;
        }
开发者ID:jrgcubano,项目名称:zetbox,代码行数:40,代码来源:ObjectReferenceHelper.cs

示例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));
 }
开发者ID:jrgcubano,项目名称:zetbox,代码行数:4,代码来源:FilterListEntryViewModel.cs

示例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));
 }
开发者ID:jrgcubano,项目名称:zetbox,代码行数:4,代码来源:CompoundObjectViewModel.cs

示例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);
            });
        }
开发者ID:daszat,项目名称:zetbox,代码行数:22,代码来源:NavigationEntryViewModel.cs

示例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));
 }
开发者ID:jrgcubano,项目名称:zetbox,代码行数:4,代码来源:FilterViewModel.cs


注:本文中的IViewModelFactory.CreateViewModel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。