Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 788269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:20:10+00:00 2026-05-14T21:20:10+00:00

I struggled to come up with a good title for this question, so suggestions

  • 0

I struggled to come up with a good title for this question, so suggestions are welcome.

Let’s say we have an abstract base class ActionBase that looks something like this:

public abstract class ActionBase
{
    public abstract string Name { get; }
    public abstract string Description { get; }

    // rest of declaration follows
}

And we have a bunch of different actions defined, like a MoveFileAction, WriteToRegistryAction, etc. These actions get attached to Worker objects:

public class Worker
{
    private IList<ActionBase> _actions = new List<ActionBase>();
    public IList<ActionBase> Actions { get { return _actions; } }

    // worker stuff ...
}

So far, pretty straight-forward. Now, I’d like to have a UI for setting up Workers, assigning Actions, setting properties, and so on. In this UI, I want to present a list of all available actions, along with their properties, and for that I’d want to first gather up all the names and descriptions of available actions (plus the type) into a collection of the following type of item:

public class ActionDescriptor
{
    public string Name { get; }
    public string Description { get; }
    poblic Type Type { get; }
}

Certainly, I can use reflection to do this, but is there a better way? Having Name and Description be instance properties of ActionBase (as opposed to statics on derived classes) smells a bit, but there isn’t an abstract static in C#.

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T21:20:10+00:00Added an answer on May 14, 2026 at 9:20 pm

    What you’re talking about is creating Metadata for your concrete Action classes to describe them. For the simple case of Name and Description, I recommend the DisplayName and Description attributes like this:

    [DisplayName("MyAction Name")]
    [Description("My description goes here")]
    public class MyAction : ActionBase
    {
        //Declaration goes here
    }
    

    These attributes are defined in System.ComponentModel.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I struggled with the title for this question, it is hard to summarize into
I've struggled with this a good bit this morning; I'm creating what will eventually
I have struggled with this for a long time, and I did get a
Have struggled with this call for a while now but i can't get it
I have struggled with this since day 1. It probably doesn't help that I've
I struggled to sum this up in a title, so apologies if it is
I have struggled with this issue for several weeks. I have Googled it and
Since I struggled a bit with this one and couldn't find a good online
Struggled to adequately describe the scenario in the question. I'm trying to learn jQuery
I struggled with this for a while, so figured I'd put the answer on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.