Class PropertyTagsExtensions
Provides extension methods for the Property class to manage tags.
Inheritance
Namespace: Umbraco.Extensions
Assembly: Umbraco.Core.dll
Syntax
public static class PropertyTagsExtensions
Methods
View SourceAssignTags(IProperty, PropertyEditorCollection, IDataTypeService, IJsonSerializer, IEnumerable<string>, bool, string?)
Assign tags.
Declaration
[Obsolete("Use the overload taking an IIdKeyMap. Scheduled for removal in Umbraco 19.")]
public static void AssignTags(this IProperty property, PropertyEditorCollection propertyEditors, IDataTypeService dataTypeService, IJsonSerializer serializer, IEnumerable<string> tags, bool merge = false, string? culture = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IProperty | property | |
| PropertyEditorCollection | propertyEditors | |
| IDataTypeService | dataTypeService | |
| IJsonSerializer | serializer | |
| IEnumerable<string> | tags | |
| bool | merge | |
| string | culture |
AssignTags(IProperty, PropertyEditorCollection, IDataTypeService, IIdKeyMap, IJsonSerializer, IEnumerable<string>, bool, string?)
Assign tags.
Declaration
public static void AssignTags(this IProperty property, PropertyEditorCollection propertyEditors, IDataTypeService dataTypeService, IIdKeyMap idKeyMap, IJsonSerializer serializer, IEnumerable<string> tags, bool merge = false, string? culture = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IProperty | property | The property. |
| PropertyEditorCollection | propertyEditors | |
| IDataTypeService | dataTypeService | |
| IIdKeyMap | idKeyMap | |
| IJsonSerializer | serializer | |
| IEnumerable<string> | tags | The tags. |
| bool | merge | A value indicating whether to merge the tags with existing tags instead of replacing them. |
| string | culture | A culture, for multi-lingual properties. |
GetTagConfiguration(IProperty, PropertyEditorCollection, IDataTypeService)
Gets the tag configuration for a property from the datatype configuration and editor tag configuration attribute.
Declaration
[Obsolete("Use the overload taking an IIdKeyMap. Scheduled for removal in Umbraco 19.")]
public static TagConfiguration? GetTagConfiguration(this IProperty property, PropertyEditorCollection propertyEditors, IDataTypeService dataTypeService)
Parameters
| Type | Name | Description |
|---|---|---|
| IProperty | property | |
| PropertyEditorCollection | propertyEditors | |
| IDataTypeService | dataTypeService |
Returns
| Type | Description |
|---|---|
| TagConfiguration |
GetTagConfiguration(IProperty, PropertyEditorCollection, IDataTypeService, IIdKeyMap)
Gets the tag configuration for a property from the datatype configuration and editor tag configuration attribute.
Declaration
public static TagConfiguration? GetTagConfiguration(this IProperty property, PropertyEditorCollection propertyEditors, IDataTypeService dataTypeService, IIdKeyMap idKeyMap)
Parameters
| Type | Name | Description |
|---|---|---|
| IProperty | property | The property. |
| PropertyEditorCollection | propertyEditors | The property editors collection. |
| IDataTypeService | dataTypeService | The data type service. |
| IIdKeyMap | idKeyMap | The cached id-to-key map used to resolve int data type IDs to GUID keys. |
Returns
| Type | Description |
|---|---|
| TagConfiguration | The tag configuration if available; otherwise, |
GetTagsValue(IProperty, PropertyEditorCollection, IDataTypeService, IJsonSerializer, string?)
Gets the tags value from a property. Used by ContentRepositoryBase.
Declaration
[Obsolete("Use the overload taking an IIdKeyMap. Scheduled for removal in Umbraco 19.")]
public static IEnumerable<string> GetTagsValue(this IProperty property, PropertyEditorCollection propertyEditors, IDataTypeService dataTypeService, IJsonSerializer serializer, string? culture = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IProperty | property | |
| PropertyEditorCollection | propertyEditors | |
| IDataTypeService | dataTypeService | |
| IJsonSerializer | serializer | |
| string | culture |
Returns
| Type | Description |
|---|---|
| IEnumerable<string> |
GetTagsValue(IProperty, PropertyEditorCollection, IDataTypeService, IIdKeyMap, IJsonSerializer, string?)
Gets the tags value from a property. Used by ContentRepositoryBase.
Declaration
public static IEnumerable<string> GetTagsValue(this IProperty property, PropertyEditorCollection propertyEditors, IDataTypeService dataTypeService, IIdKeyMap idKeyMap, IJsonSerializer serializer, string? culture = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IProperty | property | The property. |
| PropertyEditorCollection | propertyEditors | The property editors collection. |
| IDataTypeService | dataTypeService | The data type service. |
| IIdKeyMap | idKeyMap | |
| IJsonSerializer | serializer | The JSON serializer. |
| string | culture | A culture, for multi-lingual properties. |
Returns
| Type | Description |
|---|---|
| IEnumerable<string> | An enumeration of tag values. |
RemoveTags(IProperty, PropertyEditorCollection, IDataTypeService, IJsonSerializer, IEnumerable<string>, string?)
Removes tags.
Declaration
[Obsolete("Use the overload taking an IIdKeyMap. Scheduled for removal in Umbraco 19.")]
public static void RemoveTags(this IProperty property, PropertyEditorCollection propertyEditors, IDataTypeService dataTypeService, IJsonSerializer serializer, IEnumerable<string> tags, string? culture = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IProperty | property | |
| PropertyEditorCollection | propertyEditors | |
| IDataTypeService | dataTypeService | |
| IJsonSerializer | serializer | |
| IEnumerable<string> | tags | |
| string | culture |
RemoveTags(IProperty, PropertyEditorCollection, IDataTypeService, IIdKeyMap, IJsonSerializer, IEnumerable<string>, string?)
Removes tags.
Declaration
public static void RemoveTags(this IProperty property, PropertyEditorCollection propertyEditors, IDataTypeService dataTypeService, IIdKeyMap idKeyMap, IJsonSerializer serializer, IEnumerable<string> tags, string? culture = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IProperty | property | The property. |
| PropertyEditorCollection | propertyEditors | |
| IDataTypeService | dataTypeService | |
| IIdKeyMap | idKeyMap | |
| IJsonSerializer | serializer | |
| IEnumerable<string> | tags | The tags. |
| string | culture | A culture, for multi-lingual properties. |
SetTagsValue(IProperty, IJsonSerializer, object?, TagConfiguration?, string?)
Sets tags on a content property, based on the property editor tags configuration.
Declaration
public static void SetTagsValue(this IProperty property, IJsonSerializer serializer, object? value, TagConfiguration? tagConfiguration, string? culture)
Parameters
| Type | Name | Description |
|---|---|---|
| IProperty | property | The property. |
| IJsonSerializer | serializer | |
| object | value | The property value. |
| TagConfiguration | tagConfiguration | The datatype configuration. |
| string | culture | A culture, for multi-lingual properties. |
Remarks
The value is either a string (delimited string) or an enumeration of strings (tag list).
This is used both by the content repositories to initialize a property with some tag values, and by the content controllers to update a property with values received from the property editor.