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 7625425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:11:25+00:00 2026-05-31T05:11:25+00:00

Not sure how to implement this scenario: I have a base class let’s say

  • 0

Not sure how to implement this scenario:

I have a base class let’s say

   public abstract class ConfigurationBase
   {
     public int Id {get; set;}

     public string Name {get; set;}

   }

and several derived classes

   public class Config1 : ConfigurationBase
   {
     public string Url {get;set;}
     public string ReferrerUrl {get; set;}
   }


   public string Config2 : ConfigurationBase 
   {
     public string Domain {get; set;}
     public bool AllowCookie {get; set;}
   }

and a ConfigurationService which gets called with different parameters.

The idea would be that according to the parameters range to construct an instance of Config1 or Config2 or etc.

So the question is how can this be implemented in code?

Depending on same condition, instantiate a certain type.

One idea or how we had it so far, was to store the full qualified type to be instantiated in the database and construct it through reflection.

I am kind of reluctant to use this approach and I am asking if there are some other answers.

  • 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-31T05:11:26+00:00Added an answer on May 31, 2026 at 5:11 am

    If you have knowledge of all the subclasses of ConfigurationBase and the rules by which you instantiate them are the same, then you should be looking at a Factory pattern.

    If you do not have knowledge of all the subclasses, then you need to pull the type in dynamically from a data store (not necessarily a database) and instantiate it at runtime.

    If you do not know all the rules by which you instantiate the objects, you need to pull the rules from a data store and execute them.

    Obviously, the more dynamic you make it the more complexity you are going to have to deal with.

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

Sidebar

Related Questions

I've overridden Equals and GetHashCode in an abstract base class to implement value equality
Many GDI+ classes implement IDisposable, but I'm not sure when I should call Dispose.
I'm trying to implement something similar to what http://www.ancestry.com has, but I'm not sure
Not sure if this is possible or if I'm expressing correctly what I'm looking
Not sure how to ask a followup on SO, but this is in reference
Not sure if this is intended behavior or a bug or a wrong function
Not sure what's going on here. I have a DateTime object, and when I
Not sure exactly how to word this question ... so edits are welcomed! Anyway
this is a nutts job here. Not sure if jquery can handle this. I
I am not sure if this is possible but I am trying to come

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.