Interface IMetadata
A provider for metadata for something. So if an IEntity or an App has metadata, this will provide it.
[PublicApi]
public interface IMetadata : IEnumerable<IEntity>, IEnumerable, IHasPermissions, ITimestamped
- Inherited Members
Remarks
You can either loop through this object (since it's an IEnumerable
) or ask for values of the metadata,
no matter on what sub-entity the value is stored on.
Properties
Target
The identifier which was used to retrieve the Metadata. It can be used as an address for creating further Metadata for the same target.
ITarget Target { get; }
Property Value
- ITarget
Remarks
Added in v13
Methods
Get<TVal>(string)
Get the best matching value in ALL the metadata items.
TVal? Get<TVal>(string name)
Parameters
name
stringattribute name we're looking for
Returns
- TVal
A typed value.
Type Parameters
TVal
expected type, like string, int etc.
Remarks
In most scenarios, Metadata only has one additional item, so this will be accessed when using the simple Get.
If you expect objects with many metadata items which risk containing the same fields - such as Title
,
best use the more specific Get with a type-name overload to specify the type-name.
Get<TVal>(string, NoParamOrder, string?, IEnumerable<string?>?)
Get the best matching value in the metadata items.
TVal? Get<TVal>(string name, NoParamOrder noParamOrder = default, string? typeName = null, IEnumerable<string?>? typeNames = null)
Parameters
name
stringattribute name we're looking for
noParamOrder
NoParamOrdertypeName
stringOptional single type-name. If provided, will only look at metadata of that type; otherwise (or if null) will look at all metadata items and pick first match
typeNames
IEnumerable<string>List of type-name in the order it will check. If one of the values in the list is
null
, it will then check all items no matter what type. So it's common to specify preferred types first, and then anull
at the end to catch all other types.
Returns
- TVal
A typed value.
Type Parameters
TVal
expected type, like string, int etc.
Remarks
Depending on the provided type-parameters, it will only look in certain items, or all items.
History
- Name changed from old
GetBestValue
to simpleGet
in v20.
HasType(string)
Determine if something has metadata of the specified type
bool HasType(string typeName)
Parameters
typeName
stringType Name
Returns
- bool
True if there is at least one item of this type
Remarks
Added in v13
OfType(string)
Get all Metadata entities of a specific type
IEnumerable<IEntity> OfType(string typeName)
Parameters
typeName
stringType Name
Returns
Remarks
Added in v13