Class Property
Represents a property.
Namespace: Umbraco.Cms.Core.Models
Assembly: Umbraco.Core.dll
Syntax
[DataContract(IsReference = true)]
public class Property : EntityBase, IProperty, IEntity, IDeepCloneable, IRememberBeingDirty, ICanBeDirty
Constructors
View SourceProperty(int, IPropertyType)
Initializes a new instance of the Property class.
Declaration
public Property(int id, IPropertyType propertyType)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | |
| IPropertyType | propertyType |
Property(IPropertyType)
Initializes a new instance of the Property class.
Declaration
public Property(IPropertyType propertyType)
Parameters
| Type | Name | Description |
|---|---|---|
| IPropertyType | propertyType |
Properties
View SourceAlias
Returns the Alias of the PropertyType, which this Property is based on
Declaration
[DataMember]
public string Alias { get; }
Property Value
| Type | Description |
|---|---|
| string |
PropertyType
Returns the PropertyType, which this Property is based on
Declaration
[IgnoreDataMember]
public IPropertyType PropertyType { get; }
Property Value
| Type | Description |
|---|---|
| IPropertyType |
PropertyTypeId
Returns the Id of the PropertyType, which this Property is based on
Declaration
[IgnoreDataMember]
public int PropertyTypeId { get; }
Property Value
| Type | Description |
|---|---|
| int |
ValueStorageType
Returns the DatabaseType that the underlaying DataType is using to store its values
Declaration
[IgnoreDataMember]
public ValueStorageType ValueStorageType { get; }
Property Value
| Type | Description |
|---|---|
| ValueStorageType |
Remarks
Only used internally when saving the property value.
Values
Gets the list of values.
Declaration
[DataMember]
public IReadOnlyCollection<IPropertyValue> Values { get; set; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyCollection<IPropertyValue> |
Methods
View SourceConvertAssignedValue(object?)
Converts an assigned value to the appropriate type for this property.
Declaration
public object? ConvertAssignedValue(object? value)
Parameters
| Type | Name | Description |
|---|---|---|
| object | value | The value to convert. |
Returns
| Type | Description |
|---|---|
| object | The converted value, or null if conversion fails. |
CreateWithValues(int, IPropertyType, params InitialPropertyValue[])
Declaration
public static Property CreateWithValues(int id, IPropertyType propertyType, params Property.InitialPropertyValue[] values)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | |
| IPropertyType | propertyType | |
| InitialPropertyValue[] | values | Generally will contain a published and an unpublished property values |
Returns
| Type | Description |
|---|---|
| Property |
GetValue(string?, string?, bool)
Gets the value.
Declaration
public object? GetValue(string? culture = null, string? segment = null, bool published = false)
Parameters
| Type | Name | Description |
|---|---|---|
| string | culture | |
| string | segment | |
| bool | published |
Returns
| Type | Description |
|---|---|
| object |
PerformDeepClone(object)
Used by inheritors to modify the DeepCloning logic
Declaration
protected override void PerformDeepClone(object clone)
Parameters
| Type | Name | Description |
|---|---|---|
| object | clone |
PublishPartialValues(IDataEditor, string?)
Publishes partial property values for a specific culture by merging edited and published values.
Declaration
public void PublishPartialValues(IDataEditor dataEditor, string? culture)
Parameters
| Type | Name | Description |
|---|---|---|
| IDataEditor | dataEditor | The data editor used for merging values. |
| string | culture | The culture to publish values for. |
Remarks
This method is for internal use and must be invoked by the content item. It does not validate the value - the content item must validate first.
Exceptions
| Type | Condition |
|---|---|
| NotSupportedException | Thrown when attempting to publish merged culture values for culture variant properties. |
PublishValues(string?, string?)
Publishes property values for the specified culture and segment.
Declaration
public void PublishValues(string? culture = "*", string? segment = "*")
Parameters
| Type | Name | Description |
|---|---|---|
| string | culture | The culture to publish, or "*" for all cultures, or null for invariant. |
| string | segment | The segment to publish, or "*" for all segments, or null for neutral. |
Remarks
This method is for internal use and must be invoked by the content item. It does not validate the value - the content item must validate first.
SetValue(object?, string?, string?)
Sets a value.
Declaration
public bool SetValue(object? value, string? culture = null, string? segment = null)
Parameters
| Type | Name | Description |
|---|---|---|
| object | value | |
| string | culture | |
| string | segment |
Returns
| Type | Description |
|---|---|
| bool | true if the value was set (updated), false otherwise. |
Remarks
A false return value does not indicate failure, but rather that the property value was not changed (i.e. the value passed in was equal to the current property value).
UnpublishValues(string?, string?)
Unpublishes property values for the specified culture and segment.
Declaration
public void UnpublishValues(string? culture = "*", string? segment = "*")
Parameters
| Type | Name | Description |
|---|---|---|
| string | culture | The culture to unpublish, or "*" for all cultures, or null for invariant. |
| string | segment | The segment to unpublish, or "*" for all segments, or null for neutral. |
Remarks
This method is for internal use and must be invoked by the content item.