Class MaskedPropertyAttribute
Marks a generated property whose value is masked before it leaves the server, unless the user is explicitly allowed to see it in clear.
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public sealed class MaskedPropertyAttribute : Attribute
- Inheritance
-
MaskedPropertyAttribute
- Inherited Members
Remarks
The generator puts this attribute on every serialized form of a masked property: entity view class and interface, API models and lookup labels. It carries the effective mask, so that the masker can be built from the property itself.
Constructors
MaskedPropertyAttribute(string, MaskingType)
Initializes a new instance of the MaskedPropertyAttribute class.
public MaskedPropertyAttribute(string name, MaskingType type)
Parameters
namestringThe name of the masked data, used as unmasking resource:
Entity.Propertyfor a property bound to an entity property,EntityView.Propertyotherwise.typeMaskingTypeThe masking type.
Properties
MaskCharacter
Gets or sets the character that replaces each masked character.
public char MaskCharacter { get; set; }
Property Value
Name
Gets the name of the masked data, used as unmasking resource.
public string Name { get; }
Property Value
RegularExpression
Gets or sets the regular expression that designates the visible parts of the value (Regex only).
public string? RegularExpression { get; set; }
Property Value
Type
Gets the masking type.
public MaskingType Type { get; }
Property Value
VisiblePrefixLength
Gets or sets the number of characters left visible at the start of the value (Partial only).
public int VisiblePrefixLength { get; set; }
Property Value
VisibleSuffixLength
Gets or sets the number of characters left visible at the end of the value (Partial only).
public int VisibleSuffixLength { get; set; }
Property Value
Methods
GetMasker(ICustomAttributeProvider?)
Gets the masker of a property marked with MaskedPropertyAttribute.
public static ValueMasker? GetMasker(ICustomAttributeProvider? property)
Parameters
propertyICustomAttributeProviderThe property.
Returns
- ValueMasker
The masker, or null when the property is not masked.
ToSpecification()
Gets the masking specification described by the attribute.
public MaskingSpecification ToSpecification()
Returns
- MaskingSpecification
The masking specification.