-
Notifications
You must be signed in to change notification settings - Fork 230
PropertyMetadata
The PropertyMetadata
class models the metadata for a property in IdentityManager. It contains:
-
Type
: A unique identifier for the property. -
Name
: Display name for the property. -
DataType
: Type of property. Supported types are:String
Password
Email
Url
Number
Boolean
The PropertyMetadata
drives the user interface and RESTful API of IdentityManager for the properties of users and roles. The PropertyMetadata
is used to display the properties and allow editing and validation of those properties.
When a value for a property is to be assigned, the SetUserPropertyAsync
or SetRolePropertyAsync
(depending upon the context) API on the IIdentityManagerService
will be invoked. The subject, property type and value will be passed as parameters and it's up to the implementation to perform the necessary steps to set this value in the underlying identity management system.
The basic implementation of an IIdentityManagerService
would need to check the property type
when it's being assigned and then act accordingly. Given that many of these properties will map to a property on an class or to some custom logic, there are some extension methods on the PropertyMetadata
to make it more convenient to map the value to be updated. These extension methods are TrySet
and TryGet
. These are only available for a PropertyMetadata
that derives from ExecutablePropertyMetadata
and IdentityManager provides two implementations: ReflectedPropertyMetadata
and ExpressionPropertyMetadata
.
If the PropertyMetadata
is modeling a property on a class, then a reflection based implementation can be used instead via PropertyMetadata.FromProperty
or PropertyMetadata.FromPropertyName
. Then instead of the IIdentityManagerService
implementation manually checking the property type, it can use the PropertyMetadata.TrySet
extension method.
If the IIdentityManagerService
implementation needs more customization over the set or get operation for a property, the PropertyMetadata.FromFunctions
API can be used to obtain a PropertyMetadata
that maps to a pair of delegates.