学习011-06 Built-in Business Classes & Interfaces(内置业务类和接口)

Built-in Business Classes & Interfaces(内置业务类和接口)

The XAF features the Business Class Library with interfaces for XAF modules and the interface implementations for supported ORMs (XPO and EF Core).
XAF具有带有XAF模块接口的业务类库和支持的ORM(XPO和EF Core)的接口实现。
The Business Class Library consists of the following assemblies:
业务类库由以下程序集组成:
在这里插入图片描述

Interfaces for XAF Modules(XAF模块的接口)

Assembly: DevExpress.Persistent.Base.v24.1.dll
程序集:DevExpress.持久性. Base.v24.1.dll

Use service interfaces from the DevExpress.Persistent.Base.v24.1.dll assembly to integrate your business classes to XAF modules like Security System.
使用DevExpress. Perst.Base.v24.1.dll程序集中的服务接口将您的业务类集成到安全系统等XAF模块。

Interface Implementations for Supported ORMs(支持的ORM的接口实现)

Assemblies:
组件:

  • DevExpress.Persistent.BaseImpl.Xpo.v24.1.dll
  • DevExpress.Persistent.BaseImpl.EFCore.v24.1.dll

The Business Class Library allows you to do the following:
业务类库允许您执行以下操作:

  • Use classes from the DevExpress.Persistent.BaseImpl**.24.1.dll assemblies.*
    使用DevExpress. Persis.BaseImpl***.24.1.dll程序集中的类。
  • Extend persistent classes from the DevExpress.Persistent.BaseImpl**.24.1.dll assemblies to add custom functionality.*
    从DevExpress. Persis.BaseImpl***.24.1.dll程序集扩展持久类以添加自定义功能。
  • Use the DevExpress.Persistent.BaseImpl**.24.1.dll assembly sources (shipped with the XAF installation) as an example when developing your own business class library. In addition, you can modify the sources and recompile this assembly if required. Source files are located at the following path: %PROGRAMFILES%\DevExpress 24.1\Components\Sources\DevExpress.Persistent.*
    在开发您自己的业务类库时,请使用DevExpress. Perst.BaseImpl***.24.1.dll程序集源(随XAF安装一起提供)作为示例。此外,您可以修改源代码并在需要时重新编译此程序集。源文件位于以下路径:%PROGRAMFILES%\DevExpress 24.1\Components\Ssource\DevExpress.Persitent\。
  • The Business Class Library assemblies do not have references to other XAF assemblies. This allows you to use services defined there (like validation, audit trail, etc.) in non-XAF applications.
    业务类库程序集没有对其他XAF程序集的引用。这允许您在非XAF应用程序中使用那里定义的服务(如验证、审计跟踪等)。

To add a class from the Business Class Library to the UI construction process, use the ModuleBase.AdditionalExportedTypes property, or use the Exported Types section of the Module Designer.
要将业务类库中的类添加到UI构建过程,请使用ModuleBase.AdditionalExportedTypes属性,或使用模块设计器的导出类型部分。

Use the Business Class Library Customization Module to change the UI settings of the Business Class Library classes.
使用业务类库自定义模块更改业务类库类的UI设置。

Business Class Library Customization Module(业务类库定制模块)

The Business Class Library Customization module includes UI settings (Application Model differences) for XPO and Entity Framework Core classes from the Business Class Library. It specifies class icons, List View column arrangements, and Detail View layouts. To apply settings from this module, invoke the Application Designer and drag the BusinessClassLibraryCustomizationModule item from the toolbox to the Required Modules pane.
业务类库自定义模块包括业务类库中XPO和实体框架核心类的UI设置(应用程序模型差异)。它指定类图标、列表视图列排列和详细视图布局。要应用此模块中的设置,请调用应用程序设计器并将工具箱中的BusinessClassLibraryCustomizationModule项拖到所需模块窗格中。
在这里插入图片描述

The Model Editor can override Business Class Library Customization module settings.
模型编辑器可以覆盖业务类库自定义模块设置。

Note
* You can add modules to your application when you use the Solution Wizard to create a new XAF solution. Select modules in the Choose Additional Modules step.
当您使用解决方案向导创建新的XAF解决方案时,您可以将模块添加到您的应用程序中。在选择其他模块步骤中选择模块。
* To add an extra module in code, add it to the XafApplication.Modules or ModuleBase.RequiredModuleTypes list (adding a reference to the module assembly is insufficient).
要在代码中添加额外的模块,请将其添加到XafApplication. Modules或ModuleBase.必需ModuleTypes列表中(添加对模块程序集的引用是不够的)。
* In .NET applications, you can call the AddBusinessClassLibraryCustomization(IModuleBuilder) method in your ASP.NET Core Blazor/WinForms application builder.
在. NET应用程序中,可以在ASP.NETCore Blazor/WinForms应用程序构建器中调用AddBusinessClassLibraryCustomization(IModuleBuilder)方法。

Recompile the Business Class Library(重新编译业务类库)

You can modify and recompile an assembly with ready-to-use XPO or EF Core entities using the steps below.
您可以使用以下步骤使用即用型XPO或EF Core实体修改和重新编译程序集。

  • Run the Visual Studio Command Prompt as an administrator and execute the Sn.exe (Strong Name Tool) utility with the following parameters:
    以管理员身份运行Visual Studio命令提示符并使用以下参数执行Sn. exe(强名称工具)实用程序:
sn -k "%PROGRAMFILES%\DevExpress 24.1\Components\Sources\DevExpress.Key\StrongKey.snk"

This will create the strong name file (see Strong-Named Assemblies).
这将创建强名称文件(请参阅强命名程序集)。

  • Navigate to one of the following folders:
    导航到以下文件夹之一:
    • %PROGRAMFILES%\DevExpress 24.1\Components\Sources\DevExpress.Persistent\DevExpress.Persistent.BaseImpl.Xpo - if you use XPO.(如果你使用XPO。)
    • %PROGRAMFILES%\DevExpress 24.1\Components\Sources\DevExpress.Persistent\DevExpress.Persistent.BaseImpl.EFCore - if you use EF Core.(*如果您使用EF Core。)

Open the DevExpress.Persistent.BaseImpl.csproj, DevExpress.Persistent.BaseImpl.EF.csproj, or DevExpress.Persistent.BaseImpl.EFCore.NetStandard.csproj project in Visual Studio.
在Visual Studio中打开DevExpress.持久性. BaseImpl.csproj、DevExpress.持久性.BaseImpl.EF.csproj或DevExpress.持久性.BaseImpl.EFCore.NetStandard.csproj项目。

  • If you use EF, ensure that the EntityFramework.dll assembly is available. You can download it from NuGet.
    如果您使用EF,请确保EntityFramework. dll程序集可用。您可以从NuGet下载它。
  • Modify any class from the opened project.
    修改打开项目中的任何类。
  • Compile the project by clicking Rebuild in the context menu invoked for the solution. Once this rebuild is successful, the default assembly located in the %PROGRAMFILES%\DevExpress 24.1\Components\Bin\Framework folder will be replaced with the modified assembly.
    通过单击为解决方案调用的上下文菜单中的重建来编译项目。一旦重建成功,位于%PROGRAMFILES%\DevExpress 24.1\Components\bin\Framework文件夹中的默认程序集将替换为修改后的程序集。

Note
* The default path for XAF solution references is %PROGRAMFILES%\DevExpress 24.1\Components\Bin\Framework. If you use an alternate path, copy the created DevExpress.Persistent.BaseImpl.Xpo.v24.1.dll or DevExpress.Persistent.BaseImpl.EFCore.v24.1.dll assembly to the appropriate location.
XAF解决方案引用的默认路径是%PROGRAMFILES%\DevExpress
24.1\Components\bin\Framework。如果您使用备用路径,请将创建的DevExpress.持久性. BaseImpl.Xpo.v24.1.dll或DevExpress.持久性.BaseImpl.EFCore.v24.1.dll程序集复制到适当的位置。
* Some XPO-only modules (Audit Trail and Clone Object) have references to the DevExpress.Persistent.BaseImpl.Xpo.v24.1.dll library. If you are using these modules in your application, they must also be rebuilt. Refer to the following topic for details: How to rebuild assemblies from the source code.
一些仅限XPO的模块(审核跟踪和克隆对象)引用了DevExpress. Persit.BaseImpl.Xpo.v24.1.dll库。如果您在应用程序中使用这些模块,它们也必须重建。有关详细信息,请参阅以下主题:如何从源代码重建程序集。

Create Custom Classes with Class Names that Business Class Library Contains(使用业务类库包含的类名创建自定义类)

If your custom business classes are named the same way as classes from the Business Class Library (for example, Person, Address, Organization, PhoneNumber), you receive the following errors:
如果您的自定义业务类的命名方式与业务类库中的类(例如,人员、地址、组织、电话号码)相同,您会收到以下错误:

  • DuplicateModelNodeIdException at runtime or in the Model Editor.
    在运行时或模型编辑器中DuplicateModelNodeIdException。
  • View layout collisions in the Model Editor.
    在模型编辑器中查看布局冲突。

To avoid these errors, use the ModelNodesGeneratorSettings.SetIdPrefix method as follows:
要避免这些错误,请使用ModelNodesGeneratorSettings. SetIdPrefix方法,如下所示:

C#
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.DC;
using DevExpress.ExpressApp.Updating;
using DevExpress.ExpressApp.Model.NodeGenerators;


namespace MySolution.Module {
    public sealed partial class SolutionNameModule : ModuleBase {
        public override void CustomizeTypesInfo(ITypesInfo typesInfo) {
            base.CustomizeTypesInfo(typesInfo);
            ModelNodesGeneratorSettings.SetIdPrefix(
                typeof(MySolution.Module.BusinessObjects.Address),
                "AddressEx"
            );
        }
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

汤姆•猫

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值