M-Files / VAF.Extensions.Community

Community-built .NET extension methods for use with the M-Files Vault Application Framework.
MIT License
25 stars 20 forks source link

EXTENSION: Add ability to easily get the owner and default property definitions from a configured object type #105

Closed CraigHawker closed 1 year ago

CraigHawker commented 1 year ago

As raised here: https://community.m-files.com/groups-1602070992/developers/f/developer-forum/8544/automatic-mfidentifier-resolution-for-owner-propertydef

CraigHawker commented 1 year ago

~Some discussions were had as to whether these should appear for all MFIdentifier instances. Proposed using an interface as a flag.~

~Example implementation in: f5911ed67ff2af482e83585cc6fa1aa9740dae6.3 Untested, for further discussion.~

Edit: This approach causes the editors to not correctly work. It may be that the methods have to be on all MFIdentifier instances.

Edit 2: This approach won't work. Next commit will drop the custom identifier approach.

CraigHawker commented 1 year ago

Updated implementation adds to all MFIdentifier instances. Not happy about this; open to alternate approaches: c1b6c9c45e2c7ecd9c381c03118167ae4b4e4146

CraigHawker commented 1 year ago

Approach altered in f2df531a6da4febef2d59ff8489e79fade2fc9d2:

[DataContract]
class Configuration
{
    [DataMember]
    [MFObjType]
    public MFIdentifier ObjectType { get; set; }

    [DefaultPropertyDef(nameof(ObjectType))]
    public MFIdentifier DefaultPropertyDef { get; set; }

    [OwnerPropertyDef(nameof(ObjectType))]
    public MFIdentifier OwnerPropertyDef { get; set; }

}

In this way the default and owner properties are automatically populated from the object type. The user configures the object type (only), yet the default and owner property definitions are easily available (and populated automatically) via code.