Skip to content

Class DuckPropertyAttribute

Definition

Namespace: StardewUI
Assembly: StardewUI.dll

Specifies a property name to use for duck-type conversions, if different from the member name.

[System.AttributeUsage]
public class DuckPropertyAttribute : System.Attribute

Inheritance
ObjectAttribute ⇦ DuckPropertyAttribute

Remarks

This attribute is applied to the type being converted from, unlike DuckTypeAttribute which applies to the target type. It is used to match a target property with a different name, or to match multiple target properties with a single source field.

Multiple copies of the attribute can be used to match multiple target properties, with targetTypeName being used to optionally filter which type conversions it will apply to, if the data type might be used in more than one kind of conversion.

Members

Constructors

Name Description
DuckPropertyAttribute(string, string) Specifies a property name to use for duck-type conversions, if different from the member name.

Properties

Name Description
TargetPropertyName The name of the property to match on the target type.
TargetTypeName Name of the conversion target type (i.e. type with DuckTypeAttribute) to which this rename applies, not including the namespace or generic arguments. If not set, the property will be available under the specified TargetPropertyName for all conversions.
TypeId (Inherited from Attribute)

Methods

Name Description
Equals(Object) (Inherited from Attribute)
GetHashCode() (Inherited from Attribute)
IsDefaultAttribute() (Inherited from Attribute)
Match(Object) (Inherited from Attribute)

Details

Constructors

DuckPropertyAttribute(string, string)

Specifies a property name to use for duck-type conversions, if different from the member name.

public DuckPropertyAttribute(string targetPropertyName, string targetTypeName);
Parameters

targetPropertyName   string
The name of the property to match on the target type.

targetTypeName   string
Name of the conversion target type (i.e. type with DuckTypeAttribute) to which this rename applies, not including the namespace or generic arguments. If not set, the property will be available under the specified targetPropertyName for all conversions.

Remarks

This attribute is applied to the type being converted from, unlike DuckTypeAttribute which applies to the target type. It is used to match a target property with a different name, or to match multiple target properties with a single source field.

Multiple copies of the attribute can be used to match multiple target properties, with targetTypeName being used to optionally filter which type conversions it will apply to, if the data type might be used in more than one kind of conversion.


Properties

TargetPropertyName

The name of the property to match on the target type.

public string TargetPropertyName { get; }
Property Value

string


TargetTypeName

Name of the conversion target type (i.e. type with DuckTypeAttribute) to which this rename applies, not including the namespace or generic arguments. If not set, the property will be available under the specified TargetPropertyName for all conversions.

public string TargetTypeName { get; }
Property Value

string