学习008-01-04 Reuse Implemented Functionality(重用实现的功能)

Reuse Implemented Functionality(重用实现的功能)

This topic describes how to add optional modules to extend application functionality.

本主题介绍如何添加可选模块以扩展应用程序功能。

An XAF application consists of user-defined and standard XAF modules.

XAF应用程序由用户定义和标准XAF模块组成。

Modules can be platform-agnostic or platform-dependent. Platform-agnostic modules use framework features that are not specific to any platform and work on different platforms with the same code base. You can build applications for different platforms based on the same business logic if the applications refer to the same set of platform-agnostic modules.

模块可以与平台无关,也可以与平台相关。与平台无关的模块使用不特定于任何平台的框架功能,并在具有相同代码库的不同平台上工作。如果应用程序引用同一组与平台无关的模块,您可以基于相同的业务逻辑为不同的平台构建应用程序。

You can extend or modify an XAF module, use third-party modules, or create your own reusable modules.

您可以扩展或修改XAF模块、使用第三方模块或创建自己的可重用模块。

Implement Property Value Validation(实现属性值验证)

Follow the steps below to add the Validation module to your application and set up validation rules for entity objects.

按照以下步骤将验证模块添加到您的应用程序并为实体对象设置验证规则。

1.Add the DevExpress.ExpressApp.Validation.Blazor NuGet package to the SimpleProjectManager.Blazor.Server project and the DevExpress.ExpressApp.Validation.Win NuGet package to the SimpleProjectManager.Win project. See the following topic for more information on how to install DevExpress NuGet packages: Choose Between Offline and Online DevExpress NuGet Feeds.

将DevExpress. ExpressApp.Validation.Blazor NuGet包添加到SimpleProjectManager.Blazor.Server项目,将DevExpress.ExpressApp.Validation.WinNuGet包添加到SimpleProjectManager.Win项目。有关如何安装DevExpress NuGet包的更多信息,请参阅以下主题:在离线和在线DevExpress NuGet Feeds之间进行选择。

2.In the MySolution.Blazor.Server project, open the Startup.cs file and add the Validation module to the application builder. Do the same in the Startup.cs file of the MySolution.Win project:

在MySolutions. Blazor.Server项目中,打开Startup.cs文件并将验证模块添加到应用程序构建器。在MySolution.Win项目的Startup.cs文件中执行相同操作:

C#(ASP.NET Core Blazor)

csharp 复制代码
public class Startup {
// ...
    public void ConfigureServices(IServiceCollection services) {
        // ...
        services.AddXaf(Configuration, builder => {
            builder.UseApplication<MySolutionBlazorApplication>();
            builder.Modules
                // ...
                .AddValidation();
            // ...
        });
        // ...
    }
}

C#(Windows Form)

csharp 复制代码
public class ApplicationBuilder : IDesignTimeApplicationFactory {
    public static WinApplication BuildApplication(string connectionString) {
    var builder = WinApplication.CreateBuilder();
    builder.UseApplication<MySolutionWindowsFormsApplication>();
    builder.Modules
    //...
        .AddValidation();

    }
}

3.Open the SimpleProjectManager.Module\BusinessObjects\ProjectTask.cs file and apply the RuleCriteriaAttribute to the ProjectTask class:

打开SimpleProjectManager. Module\BusinessObjects\ProjectTask.cs文件并将RuleCriteriaAttribute应用于ProjectTask类:

C#

csharp 复制代码
using DevExpress.Persistent.Validation;
// ...
[RuleCriteria("EndDate >= StartDate", 
    CustomMessageTemplate = "Start Date must be less than End Date")]
public class ProjectTask : BaseObject {
    // ...
}

4.Run the application and change the task's end date. When you save the changes, XAF validates the task according to specified settings.

运行应用程序并更改任务的结束日期。保存更改时,XAF会根据指定的设置验证任务。

ASP.NET Core Blazor

Windows Forms

Highlight Property Editors(突出显示属性编辑器)

Follow the steps below to add the Conditional Appearance module to your application and highlight all tasks whose status is "In progress".

按照以下步骤将条件外观模块添加到您的应用程序并突出显示状态为"In progress"的所有任务。

1.Add the DevExpress.ExpressApp.ConditionalAppearance NuGet package to the SimpleProjectManager.Module project.

将DevExpress. ExpressApp.ConditionalAppearance NuGet包添加到SimpleProjectManager模块项目。

2.In the Solution Explorer, go to the SimpleProjectManager.Module project and open the Module.cs file. Add the Conditional Appearance module to the RequiredModuleTypes collection.

在解决方案资源管理器中,转到SimpleProjectManager.Module项目并打开Module.cs文件。将条件外观模块添加到必需的模块类型集合中。

C#

csharp 复制代码
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Updating;

namespace SimpleProjectManager.Module;

public sealed class SimpleProjectManagerModule : ModuleBase {
    public SimpleProjectManagerModule() {
        // ...
        RequiredModuleTypes.Add(typeof(DevExpress.ExpressApp.ConditionalAppearance.ConditionalAppearanceModule));
    }

    // ...
}

3.Open the ProjectTask class and apply AppearanceAttribute as displayed in the code sample below:

打开ProjectTask类并应用外观属性,如下面的代码示例所示:

C#

csharp 复制代码
// ...
using DevExpress.ExpressApp.ConditionalAppearance;

namespace SimpleProjectManager.Module.BusinessObjects
{
    // ...
    [Appearance("InProgress", TargetItems = "Subject;AssignedTo",
    Criteria = "Status = 1", BackColor = "LemonChiffon")]
    public class ProjectTask : BaseObject
    {
        // ...
    }

    // ...
}

4.Run the application. The task whose status is "In progress" is highlighted now.

运行应用程序。现在突出显示状态为"In progress"的任务。

ASP.NET Core Blazor -- List View

ASP.NET Core Blazor -- Detail View

Windows Forms -- List View

Windows Forms -- Detail View

相关推荐
D11_3 分钟前
阿里云服务器百度站长平台验证完整指南:SSH文件验证详解
服务器·百度·阿里云
EndingCoder11 分钟前
Node.js 数据查询优化技巧
服务器·javascript·数据库·node.js·数据查询优化
TDengine (老段)11 分钟前
TDengine 数学函数 SIGN 用户手册
大数据·数据库·sql·时序数据库·iot·tdengine·涛思数据
RestCloud25 分钟前
Kingbase 与 ETL:如何实现金融级数据库的安全数据同步
数据库·数据安全·etl·数据处理·数据传输·数据同步·kingbase
Elastic 中国社区官方博客1 小时前
在 Elastic Observability 中,启用 TSDS 集成可节省高达 70% 的指标存储
大数据·运维·数据库·elasticsearch·搜索引擎·全文检索·时序数据库
Thepatterraining1 小时前
MySQL数据存储黑科技:Page布局、行存储与压缩算法全解密
数据库·mysql
九年义务漏网鲨鱼1 小时前
从零学习 Agentic RL(四)—— 超越 ReAct 的线性束缚:深入解析 Tree-of-Thoughts (ToT)
前端·学习·react.js
RedCong1 小时前
gitops无法连接到Openshift集群
运维·服务器·openshift
天***88962 小时前
怎么卸载或禁用 WPS office的wps看图软件?怎么关闭wps看图软件。或者怎么彻底删除wps?
运维·服务器·wps
wan5555cn2 小时前
中国启用WPS格式进行国际交流:政策分析与影响评估
数据库·人工智能·笔记·深度学习·算法·wps