• How to: 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.

    本主题演示如何实现具有文件数据属性和文件集合属性的业务部门类。为此,将实现用于存储和管理员工简历信息的"简历"类。它有三个属性:文件、联系人和组合。File 属性提供一个文件,联系人属性包含对联系人类的引用,并且项目组合属性返回员工文件的集合。

    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 and/or FileAttachmentMobileModule modules should be added to your WinForms, ASP.NET Web and/or Mobile module projects respectively. These modules contain Property Editors for IFileData type properties, and Controllers with Actions that are necessary for file manipulation. Note that the Mobile Property Editor for a IFileData property supports only the file download. For details, refer to the File Attachments Module Overview topic.

    要将文件数据类型属性和文件集合属性添加到业务对象,应使用实现 IFileData 接口的类型和应用 File 附件属性的类型。在这种情况下,文件附件WindowsForms模块、文件附件AspNet模块和/或文件附件移动模块模块应分别添加到您的WinForms、ASP.NET Web和/或移动模块项目中。这些模块包含 IFileData 类型属性的属性编辑器,以及具有文件操作所需的操作的控制器。请注意,IFileData 属性的移动属性编辑器仅支持文件下载。有关详细信息,请参阅文件附件模块概述主题。

    To add the FileAttachmentsWindowsFormsModule, FileAttachmentsAspNetModule and (or) FileAttachmentMobileModule module(s) to the application, invoke the Module Designer for the WinForms, ASP.NET and (or) Mobile module project(s), drag the corresponding item from the Toolbox to the Designer's Required Modules section, and rebuild the solution.

    要向应用程序添加文件附件WindowsForms模块、文件附件AspNet模块和(或)文件附件移动模块模块,请调用WinForms的模块设计器,ASP.NET和(或)移动模块项目,拖动相应的项目从工具箱到"设计器所需的模块"部分,然后重建解决方案。

    The following code demonstrates a Resume business object.

    以下代码演示了"恢复"业务对象。

    [DefaultClassOptions]
    public class Resume : BaseObject {
       public Resume(Session session) : base(session) {}
       private Contact contact;
       private FileData file;
       [Aggregated, ExpandObjectMembers(ExpandObjectMembers.Never)]
       public FileData File {
          get { return file; }
          set {
             SetPropertyValue(nameof(File), ref file, value);
          }
       }
       public Contact Contact {
          get { 
             return contact;
          }
          set {
             SetPropertyValue(nameof(Contact), ref contact, 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<PortfolioFileData> type. The PortfolioFileData class is inherited from the FileAttachmentBase class, which in turn, uses the FileAttachment interface. The FileAttachmentBase class, as well as the FileAttachment attribute, is from the Business Objects Library.

    要创建员工文件的集合,"简历"类具有 XPCollection<PortfolioFileData> 类型的"项目组合"属性。包库文件数据类是从文件附件库类继承的,后者又使用文件附件接口。文件附件库类以及文件附件属性来自业务对象库。

    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.

    包包文件数据类具有文档类型属性,用于指定组合文件类型。此属性在"构建后"方法重写中初始化。包包文件数据类还在其 Resume 属性中存储对"简历"对象的引用。

    The following images show the Resume Detail View in WinForms, ASP.NET Web and Mobile applications.

    下图显示了 WinForms 中的"简历详细信息",ASP.NET Web 和移动应用程序。

    ResumeInWin

    ResumeInWeb

    ResumeInMobile

     
  • 相关阅读:
    Microsoft Exchange Mail Flow Rule
    Microsoft Exchange Inactive mailbox
    Microsoft Exchange In-Place Hold and Litigation Hold
    Microsoft Exchange eDiscovery
    Microsoft Exchange Retention Policy
    JavaScript Array 操作
    CSS选择器优先级
    CSS实现垂直居中
    watch和computed和methods区别是什么?
    什么是async和await? 怎么捕获异常?
  • 原文地址:https://www.cnblogs.com/foreachlife/p/How-to-Implement-File-Data-Properties.html
Copyright © 2020-2023  润新知