Shell

程序入口继承自SmartClientApplication,WorkItem是CompositeUI默认的WorkItem,ShellForm是普通的Form,在ShellForm中定义了一个Name属性为"LayoutWorkspace"的 Private Microsoft.Practices.CompositeUI.WinForms.DeckWorkspace _layoutWorkspace,

public class ShellApplication : SmartClientApplication<WorkItem, ShellForm> { /// <summary> /// Application entry point. /// </summary> [STAThread] static void Main() { #if (DEBUG) RunInDebugMode(); #else RunInReleaseMode(); #endif } ...

在SmartClientApplication中做了较多工作,代码如下:

public abstract class SmartClientApplication<TWorkItem, TShell> : FormShellApplication<TWorkItem, TShell> where TWorkItem : WorkItem, new() where TShell : Form { protected override void AddBuilderStrategies(Builder builder) { base.AddBuilderStrategies(builder); builder.Strategies.AddNew<ActionStrategy>(BuilderStage.Initialization); } protected override void AddServices() { base.AddServices(); // Authentication services RootWorkItem.Services.AddNew<UserSelectorService, IUserSelectorService>(); RootWorkItem.Services.Remove<IAuthenticationService>(); RootWorkItem.Services.AddNew<SimpleWinFormAuthenticationService, IAuthenticationService>(); RootWorkItem.Services.AddNew<SimpleRoleService, IRoleService>(); // Profile catalog services RootWorkItem.Services.AddNew<ProfileCatalogService, IProfileCatalogService>(); //Add the InfoStore service we want to use //RootWorkItem.Services.AddNew<ProfileCatalogModuleInfoStore, IModuleInfoStore>(); RootWorkItem.Services.AddNew<WebServiceCatalogModuleInfoStore, IModuleInfoStore>(); RootWorkItem.Services.Remove<IModuleEnumerator>(); RootWorkItem.Services.Remove<IModuleLoaderService>(); RootWorkItem.Services.AddNew<XmlStreamDependentModuleEnumerator, IModuleEnumerator>(); RootWorkItem.Services.AddNew<DependentModuleLoaderService, IModuleLoaderService>(); RootWorkItem.Services.AddNew<ActionCatalogService, IActionCatalogService>(); IUIElementAdapterFactoryCatalog catalog = RootWorkItem.Services.Get<IUIElementAdapterFactoryCatalog>(); catalog.RegisterFactory(new LinkLabelPanelUIAdapterFactory()); RootWorkItem.Services.AddNew<WorkspaceLocatorService, IWorkspaceLocatorService>(); RootWorkItem.Services.AddNew<EntityTranslatorService, IEntityTranslatorService>(); } protected override void BeforeShellCreated() { base.BeforeShellCreated(); InitializeWebServiceCatalogModuleInfoStore(); } private void InitializeWebServiceCatalogModuleInfoStore() { IRoleService roleService = RootWorkItem.Services.Get<IRoleService>(); WebServiceCatalogModuleInfoStore store = RootWorkItem.Services.Get<IModuleInfoStore>() as WebServiceCatalogModuleInfoStore; store.Roles = roleService.GetRolesForUser(Thread.CurrentPrincipal.Identity.Name); } protected override void AfterShellCreated() { base.AfterShellCreated(); ShellNotificationService notificationService = new ShellNotificationService(this.Shell); RootWorkItem.Services.Add(typeof (IMessageBoxService), notificationService); } }

加入了一个Stratagey(ActionStrategy)

public override object BuildUp(IBuilderContext context, Type typeToBuild, object existing, string idToBuild) { WorkItem workItem = GetWorkItem(context, existing); if (workItem != null) { IActionCatalogService actionCatalog = workItem.Services.Get<IActionCatalogService>(); if (actionCatalog != null) { Type targetType = existing.GetType(); foreach (MethodInfo methodInfo in targetType.GetMethods()) RegisterActionImplementation(context, actionCatalog, existing, idToBuild, methodInfo); } } private void RegisterActionImplementation(IBuilderContext context, IActionCatalogService catalog, object existing, string idToBuild, MethodInfo methodInfo) { foreach (ActionAttribute attr in methodInfo.GetCustomAttributes(typeof(ActionAttribute), true)) { ActionDelegate actionDelegate = (ActionDelegate)Delegate.CreateDelegate(typeof(ActionDelegate), existing, methodInfo); catalog.RegisterActionImplementation(attr.ActionName, actionDelegate); // TODO: Add to resources TraceBuildUp(context, existing.GetType(), idToBuild, "Action implementation built for action {0}, for the method {1} on the type {2}.", attr.ActionName, methodInfo.Name, existing.GetType().Name); } }

在ModuleActions中集中写动作代码,在方法上打上“[Action("ActionName")]”标记,ActionStrategy将标记的方法新建代理都注册到ActionCatalogService中的Dictionary<string, ActionDelegate>集合中,这样在其他地方就可以简单的用ActionCatalog.Execute(“ActionNames”, WorkItem, this, null)的方法调用

[Action(ActionNames.ShowCustomerQueueManagementView)] public void ShowCustomerQueueManagementView(object caller, object target) { CustomerQueueManagementView view = WorkItem.Items.AddNew<CustomerQueueManagementView>(); WorkItem.Workspaces[WorkspaceNames.LaunchBarWorkspace].Show(view); WorkItem.RootWorkItem.UIExtensionSites.RegisterSite(UIExtensionSiteNames.CustomerQueueLinks, view.LinksPanel); }

在ModuleController中调用,ModuleController继承自WorkItemController

public override void Run() { ExecuteActions(); ShowDefaultView(); } private void ExecuteActions() { WorkItem.Items.AddNew<ModuleActions>(); ActionCatalog.Execute(ActionNames.ShowCustomerQueueManagementView, WorkItem, this, null); ActionCatalog.Execute(ActionNames.ShowOfficerQueueView, WorkItem, this, null); ActionCatalog.Execute(ActionNames.ServiceCustomerAction, WorkItem, this, null); ActionCatalog.Execute(ActionNames.ShowAddVisitorToQueueCommand, WorkItem, this, null); ActionCatalog.Execute(ActionNames.ShowFindCustomerCommand, WorkItem, this, null); }

服务

在SmartClientApplication中加载的服务:

  • UserSelectorService,提供用户登录验证服务,在SelectUser方法中调用UserSelectionForm登录
  • SimpleWinFormAuthenticationService,根据登录的用户完成系统认证,使用到了Thread.CurrentPrincipal
public void Authenticate() { IUserData user = _userSelector.SelectUser(); if (user != null) { GenericIdentity identity = new GenericIdentity(user.Name); GenericPrincipal principal = new GenericPrincipal(identity, user.Roles); Thread.CurrentPrincipal = principal; } else { throw new AuthenticationException(Resources.NoUserProvidedForAuthentication); } }
  • SimpleRoleService,根据用户名得到角色
  • ProfileCatalogService,演示了通过WebService获取用户的Profile的简单实现,
  • WebServiceCatalogModuleInfoStore,利用ProfileCatalogService从WebService服务端取得文件字符串的功能取得在服务端定义的模块信息
  • XmlStreamDependentModuleEnumerator,解析WebServiceCatalogModuleInfoService返回的Xml字符串取得模块的枚举
  • DependentModuleLoaderService,模块加载服务,根据XmlStreamDependentModuleEnumerator的模块信息Load模块
  • ActionCatalogService,动作集中管理服务,提供动作的注册、执行等功能
public interface IActionCatalogService { bool CanExecute(string action, WorkItem context, object caller, object target); bool CanExecute(string action); void Execute(string action, WorkItem context, object caller, object target); void RegisterSpecificCondition(string action, IActionCondition actionCondition); void RegisterGeneralCondition(IActionCondition actionCondition); void RemoveSpecificCondition(string action, IActionCondition actionCondition); void RemoveGeneralCondition(IActionCondition actionCondition); void RemoveActionImplementation(string action); void RegisterActionImplementation(string action, ActionDelegate actionDelegate); }
  • WorkspaceLocatorService,查找SmartPart所在的Workspace
  • EntityTranslatorService,实体翻译

转载于:https://www.cnblogs.com/Wingedox/archive/2007/07/30/835834.html

CompositeUI Demo BankBranchWorkbench相关推荐

  1. jquery autocomplete demo

    根据用户输入值进行搜索和过滤,让用户快速找到并从预设值列表中选择. jquery.autocomplete参考地址 http://bassistance.de/jquery-plugins/jquer ...

  2. BERT-Pytorch demo初探

    https://zhuanlan.zhihu.com/p/50773178 概述 本文基于 pytorch-pretrained-BERT(huggingface)版本的复现,探究如下几个问题: py ...

  3. MinkowskiEngine demo ModelNet40分类

    MinkowskiEngine demo ModelNet40分类 本文将看一个简单的演示示例,该示例训练用于分类的3D卷积神经网络.输入是稀疏张量,卷积也定义在稀疏张量上.该网络是以下体系结构的扩展 ...

  4. Android - 下载别人的android demo 运行的时候加载很久问题处理

    一般从git 下载别人的demo 的时候每次都要加载很久,下载gradle 版本之类的, 处理方法把 gradle 下面的 gradle-wrapper 里面的distributionUrl 替换自己 ...

  5. android studio导入第三方库和demo

    导demo,导第三方库,都可以用这个方法,别想太复杂了, file - new - import module

  6. iOS蓝牙开发---CoreBluetooth[BLE 4.0] 初级篇[内附Demo地址]

    一.蓝牙基础知识 (一)常见简称 1.MFI  make for ipad ,iphone, itouch 专们为苹果设备制作的设备,开发使用ExternalAccessory 框架(认证流程貌似挺复 ...

  7. 【应用篇】Activiti外置表单实例demo(四)

    在这里我想说的外置表单.是说我们将我们自己的jsp(.form,.html)等页面上传到工作流的数据库中,当任务运行到当前结点时.给我们像前台发送绑定好的表单. 此处是给表单绑定表单的过程 不允许为: ...

  8. 【camera】自动泊车-视觉车位检测相关资料汇总(论文、数据集、源代码、相关博客、演示demo)(1)

    [camera]自动泊车-视觉车位检测相关资料汇总(论文.数据集.源代码.相关博客.演示demo)parking slot detection 论文 2020论文 2019论文 2018论文 2017 ...

  9. 【camera】自动泊车-基于深度学习的视觉车位检测项目(课程设计--训练代码、测试代码、部署demo)(2)

    **基于深度学习的点定位回归和角度预测的车位检测 基于深度学习的点定位回归和角度预测 基于深度学习的角点检测和角度回归 ** 项目下载地址:训练代码.测试代码.部署demo 数据集百度网盘下载:数据集 ...

  10. CornerNet:实现demo、可视化heatmap、测试各类别精度

    CornerNet:实现demo.可视化heatmap.测试各类别精度 文章目录 CornerNet:实现demo.可视化heatmap.测试各类别精度 前言 实现demo 方案一 方案二 可视化he ...

最新文章

  1. java中的异常及其处理
  2. macbookpro升级后打不开eclipse_维修分享——面容坏升级iOS13系统后 导致前后摄像头都打不开...
  3. 《编写高质量代码:改善c程序代码的125个建议》——建议14-2:在右移中合理地选择0或符号位来填充空出的位...
  4. 论文学习9-Bidirectional LSTM-CRF Models for Sequence Tagging(LSTM,BILSTM,LSTM-CRF,BILSTM-CRF
  5. 讲座记录——大数据共享和交易的挑战与初探
  6. Android 系统(165)---在apns-conf文件中配置一个read_only字段,使APN不可被编辑
  7. 特斯拉上海超级工厂Model Y日产量达到1000辆 超过Model 3
  8. 新职业英语计算机unit5,新职业英语2Unit5.ppt
  9. 怎么让同网络计算机强制关机,知道局域网ip怎么关机
  10. Protocol Buffers C++ 入门教程
  11. css实现背景全透明样式
  12. 匹配滤波器的MATLAB实现
  13. 编码解码 Base64 Base32 Base16
  14. 浊音、清音、爆破音的时域频域分析
  15. 职场最高级的聪明是靠谱,到底一个人怎样才算真正靠谱?
  16. 真正实现网络下载,文件不落地.解决XmlHttp对象、winnet.dll、URLDownloadToFile生成的ie缓存(Hook_CreateFileW阻止缓存生成)
  17. IDEA/GoLand 添加自定义特殊注释【注释高亮】
  18. InputStream输入字节流
  19. 基于 electron 实现简单易用的抓包、mock 工具
  20. 计算机安全类论文题目,★计算机络安全论文题目计算机络安全毕业论文题目大全计算机络安全论文选题参考...

热门文章

  1. c++ win32 获取串口高低电平_串口和USB的区别,几种常见的串口协议
  2. Leetcode44. Wildcard Matching
  3. 力扣-507 完美数
  4. Android 两个App间进行IPC通信
  5. Flutter学习 — 用占位符淡入淡出的显示图片
  6. Dart基础第9篇:对象、类
  7. Android调试wifi使用wpa_supplicant和wpa_cli总结
  8. C++远征离港篇-学习笔记
  9. 微信端支付宝支付,iframe改造,解决微信中无法使用支付宝付款和弹出“长按地址在浏览器中打开”...
  10. mybatis对mysql进行分页