学习011-03-11 Implement File Data Properties(实现文件数据属性)

Implement File Data Properties(实现文件数据属性)

This topic demonstrates how to implement a business class with a file data property and a file collection property. For this purpose, the Resume class, which is used to store and manage an employee’s resume information, is implemented. It has three properties: File, Contact and Portfolio. The File property provides a file, the Contact property contains a reference to the Contact class, and the Portfolio property returns a collection of the employee’s files.
本主题演示了如何实现具有文件数据属性和文件集合属性的业务类。为此,实现了用于存储和管理员工简历信息的Resume类。它有三个属性:File、Contand Portfolio。File属性提供一个文件,touch属性包含对touch类的引用,Portfolio属性返回员工文件的集合。

To add a file data type property and a file collection property to a business object, you should use a type that implements the IFileData interface and one that applies the FileAttachment attribute. In this instance, the FileAttachmentsWindowsFormsModule, FileAttachmentsAspNetModule, or FileAttachmentsBlazorModule modules should be added to your WinForms, ASP.NET Web, or ASP.NET Core Blazor module projects respectively. If your solution does not contain these projects, add it to application projects. These modules contain Property Editors for IFileData type properties, and Controllers with Actions that are necessary for file manipulation. For details, refer to the File Attachments Module Overview topic.
要向业务对象添加文件数据类型属性和文件集合属性,您应该使用一个实现IFileData接口的类型和一个应用Fileattap属性的类型。在这种情况下,FileAttachmentsWindowsFormsModule、FileAttachmentsAspNetModule或FileAttachmentsBlazorModule模块应该分别添加到WinForms、ASP.NET Web或ASP.NET Core Blazor模块项目中。如果您的解决方案不包含这些项目,请将其添加到应用程序项目中。这些模块包含IFileData类型属性的属性编辑器,以及文件操作所需的带有操作的控制器。有关详细信息,请参阅文件附件模块概述主题。

To add the FileAttachmentsWindowsFormsModule or FileAttachmentsAspNetModule module to a .NET Framework application, invoke the Module Designer for the WinForms or ASP.NET Web Forms module project, drag the corresponding item from the Toolbox to the Designer’s Required Modules section, and rebuild the solution.
要将FileAttachmentsWindowsFormsModule或FileAttachmentsAspNetModule模块添加到. NET Framework应用程序,请为WinForms或ASP.NET Web Forms模块项目调用模块设计器,将相应项目从工具箱拖到设计器的必需模块部分,然后重建解决方案。

To add the FileAttachmentsWindowsFormsModule or FileAttachmentsBlazorModule module to a .NET application, install the DevExpress.ExpressApp.FileAttachment.Win or DevExpress.ExpressApp.FileAttachment.Blazor NuGet package to the WinForms or ASP.NET Core Blazor module project. If your solution does not contain these projects, add the corresponding project to an application project. Add the File Attachment Module to the platform-specific module’s RequiredModuleTypes collection. Rebuild the solution. For more information, refer to the Reuse Implemented Functionality topic.
要将FileAttachmentsWindowsFormsModule或FileAttachmentsBlazorModule模块添加到. NET应用程序,请将DevExpress.ExpressApp.FileAttachment.Win或DevExpress.ExpressApp.Fileattachment.Blazor NuGet包安装到WinForms或ASP.NET Core Blazor模块项目中。如果您的解决方案不包含这些项目,请将相应的项目添加到应用程序项目中。将文件附件模块添加到特定于平台的模块的必需模块类型集合中。重建解决方案。有关详细信息,请参阅重用已实现的功能主题。

Tip
In .NET applications, you can call the AddFileAttachments(IModuleBuilder<IWinApplicationBuilder>, Action<FileAttachmentsOptions>) method in your ASP.NET Core Blazor/WinForms application builder.
在. NET应用程序中,您可以在ASP.NET Core Blazor/WinForms应用程序构建器中调用AddFileattachments(IModuleBuilder<IWinApplicationBuilder>,Action<FileAttachmentsOptions>)方法。

The following code demonstrates a Resume business object.
以下代码演示了Resume业务对象。

C#
[DefaultClassOptions]
public class Resume : BaseObject {
   public Resume(Session session) : base(session) {}
   private FileData file;
   [Aggregated, ExpandObjectMembers(ExpandObjectMembers.Never)]
   public FileData File {
      get { return file; }
      set {
         SetPropertyValue(nameof(File), ref file, value);
      }
   }
  [Aggregated, Association("Resume-PortfolioFileData")]
  public XPCollection<PortfolioFileData> Portfolio {
     get { return GetCollection<PortfolioFileData>(nameof(Portfolio)); }
  }
}
public class PortfolioFileData : FileAttachmentBase {
   public PortfolioFileData(Session session) : base(session) {}
   private DocumentType documentType;
   protected Resume resume;
   [Persistent, Association("Resume-PortfolioFileData")]
   public Resume Resume {
      get { return resume; }
      set {
         SetPropertyValue(nameof(Resume), ref resume, value);
      }
   }
   public override void AfterConstruction() {
      base.AfterConstruction();
      documentType = DocumentType.Unknown;
   }
   public DocumentType DocumentType {
      get { return documentType; }
      set { SetPropertyValue(nameof(DocumentType), ref documentType, value);}
   }
}
public enum DocumentType { SourceCode = 1, Tests = 2, Documentation = 3,
   Diagrams = 4, ScreenShots = 5, Unknown = 6 };

To create a collection of an employee’s files, the Resume class has the Portfolio property of the XPCollection type. The PortfolioFileData class is inherited from the FileAttachmentBase class, which in turn, uses the FileAttachment interface. The FileAttachmentBase class and the FileAttachment attribute are the parts of the Business Objects Library.
为了创建员工文件的集合,Resume类具有XPCollection类型的Portfolio属性。PortfolioFileData类继承自FileattachmentBase类,而FileattachmentBase类又使用FileattachmentBase接口。FileattachmentBase类和FileAtt属性是业务对象库的组成部分。

The PortfolioFileData class has the DocumentType property that specifies the portfolio file type. This property is initialized in the AfterConstruction method override. The PortfolioFileData class also stores a reference to a Resume object in its Resume property.
PortfolioFileData类具有指定投资组合文件类型的DocumentType属性。此属性在AfterBuild方法覆盖中初始化。PortfolioFileData类还在其Resume属性中存储对Resume对象的引用。

The following images show the Resume Detail View in WinForms, ASP.NET Web, and ASP.NET Core Blazor applications.
以下图像显示了WinForms、ASP.NET Web和ASP.NET Core Blazor应用程序中的简历详细信息视图。
WinForms
在这里插入图片描述

ASP.NET Web Forms
在这里插入图片描述

Blazor
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

汤姆•猫

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

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

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

打赏作者

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

抵扣说明:

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

余额充值