© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
40 replies
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;
    }
}
[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;
    }
}
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;
schemaItem.ParsecMetadata.Group = Group;
in all attributes that inherit
UIControlAttribute
UIControlAttribute

I know that I can call
base.FillSchema( schemaItem, property, culture );
base.FillSchema( schemaItem, property, culture );
but maybe there is better way to do the same?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ base class/abstract for record
C#CC# / help
3y ago
Mocking derived class with abstract base class
C#CC# / help
4y ago
Any way to inherit base abstract class' constructor?
C#CC# / help
2y ago
❔ abstract class virtual methods vs default implementation interface
C#CC# / help
4y ago