C#C
C#3y ago
SWEETPONY

✅ How to call base implementation in abstract class?

I have following abstract class:
[AttributeUsage( AttributeTargets.Property | AttributeTargets.Field )]
public abstract class UIControlAttribute
    : Attribute
{
    [JsonProperty(PropertyName = "group")]
    public string Group { get; set; }

    public virtual void FillSchema(
        UISchemaItem schemaItem,
        PropertyInfo property,
        CultureInfo culture)
    {
        if ( Group != null )
            schemaItem.ParsecMetadata.Group = Group;
    }
}


Usage:
public class UIControlAesKeyAttribute
    : UIControlAttribute
{
    public override void FillSchema(
        UISchemaItem schemaItem,
        PropertyInfo property,
        CultureInfo culture)
    {
        schemaItem.Type = "string";

        schemaItem.ParsecMetadata ??= new();
        schemaItem.ParsecMetadata.UIControlInputType = UIControlInputType.AesKey;
    }
}


The problem: I want to do schemaItem.ParsecMetadata.Group = Group; in all attributes that inherit UIControlAttribute
I know that I can call base.FillSchema( schemaItem, property, culture ); but maybe there is better way to do the same?
Was this page helpful?