什么是 Caliburn 验证抽象

发布于 2024-10-09 23:20:21 字数 451 浏览 2 评论 0原文

最近我看到这个文档指定了如何Caliburn 很棒(并不是真的将它与微框架进行比较,这就足够了)。 我在 Caliburn 工作了一年多,对它了解不多。

所以也许有人可以解释以下内容(其中一些我可以理解,但不知道与 caliburn 的关系):

  1. 验证抽象
  2. 模块框架
  3. 基于 ExpressionTree 的运行时委托生成
  4. ViewModelFactory
  5. ShellFramework

我正在使用 V1.1,所以如果有新内容2.0就说属于新版本吧,以后大概会学习的。

Recently I saw this document that specify how great is Caliburn(Not really it compares it to the micro framework, and thats enough).
I'm working with Caliburn for more than a year and don't know many things about it.

So maybe someone can explain the following(Some of it I can understand but have no iea about the relation to caliburn):

  1. Validation abstraction
  2. module framework
  3. ExpressionTree-Based runtime delegate generation
  4. ViewModelFactory
  5. ShellFramework

I'm working with V1.1 so if something is new in 2.0, just say it belong to the new version I'll learn it probably in the future.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

握住你手 2024-10-16 23:20:21
  1. 验证抽象的目的是在 ViewModel 中插入验证基础设施。
    Caliburn 的 DefaultValidator 使用 System.ComponentModel.DataAnnotations,但也可以使用 Fluent Validation 的适配器。
    虽然验证可以直接从应用程序代码中使用,但框架主要在 AOP 验证行为中使用它,该行为为模型提供自动 IDataErrorInfo 实现。

    如果您的模型已经实现了 IDataErrorInfo,Caliburn 就能够利用普通 WPF 绑定来挂钩验证(作为传统绑定过程的一部分)。
    然而,手动实现 IDataErrorInfo 很无聊,并且可能会导致难以维护的代码,因此引入了 AOP [ValidateAttribute]
    要启用它,您必须配置容器以使用可用的代理工厂(基于 Castle.DynamicProxy):

    myContainerAdapter
    .WithProxyFactory()

    这指示容器适配器检查应用于从容器中拉出的 ViewModel(和其他组件)的行为属性,并创建它们的子类来实现指定的行为。

    [Validate] 行为实现只是将“IDataErrorInfo”调用委托给实际的 IValidator 服务。

  2. Caliburn 本身使用模块框架来管理其自身模块的配置和初始化。它还可以用于创建独立的应用程序模块:Caliburn 将负责发现它们(如果它们的程序集在 IAssemblySource 中注册)并驱动它们的初始化;

  3. Caliburn 不使用反射来调用操作,而是利用表达式树动态构建委托来创建已编译的 lambda;
  4. Caliburn 使用 ViewModelFactory 服务来抽象 VM 的创建,可以按类型或按主题处理;
  5. ShellFramework 包含一组可用于构建大多数应用程序的工具;它包括一些自定义的 IResult(以及创建它们的流畅式静态方法)和一些预构建的 ViewModel(菜单和问题/消息对话框)来完成常见的应用程序任务。
  1. The validation abstraction is aimed to plug a validation infrastructure in ViewModels.
    Caliburn's DefaultValidator uses System.ComponentModel.DataAnnotations, but an adapter for Fluent Validation is also available.
    While the validation could be used directly from application code, it is used by the framework mainly in the AOP validation behavior, which provides an automatic IDataErrorInfo implementation for models.

    If your models already implement IDataErrorInfo, Caliburn is able to hook the validation (as a part of conventional binding process) leveraging plain WPF binding.
    Yet, implementing IDataErrorInfo manually is boring and likely to lead to hardly mantainable code, so the AOP [ValidateAttribute] was introduced.
    To enable it, you have to configure your container to use the available proxy factory (which is based upon Castle.DynamicProxy):

    myContainerAdapter
    .WithProxyFactory<Caliburn.DynamicProxy.DynamicProxyFactory>()

    This instructs the container adapter to inspect behaviors attribute applied on the ViewModels (and other components) pulled from the container, and to create a subclass of them implementing the specified behavior.

    The [Validate] behavior implementation just delegates 'IDataErrorInfo' calls to the actual IValidator service.

  2. Module framework is used by Caliburn itself to manage configuration and initialization of its own modules. It could also be used to create independent application modules: Caliburn will take care of discovering them (if their assemblies are registered in IAssemblySource) an drive their initialization;

  3. Caliburn doesn't use reflection to invoke action, but builds delegates on the fly leveraging Expression Trees to create a compiled lambda;
  4. The ViewModelFactory service is used by Caliburn to abstract the creation of VM, either by type or by Subject handled;
  5. ShellFramework contains a set of facility useful to build most applications; it includes some custom IResult (along with fluent-style static methods to create them) and some pre-built ViewModels (Menus and Question/Message dialog) to accomplish common application tasks.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文