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

  • Home
  • SEARCH
  • 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 8988771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:05:17+00:00 2026-06-15T22:05:17+00:00

I am creating a factory which uses a delegate to call a static method

  • 0

I am creating a factory which uses a delegate to call a static method on each registred type in order to create an instance of the type.

In the factory I have the delegate definition:

public delegate GridColumnBase ColumnFactoryMethod();

and I would like each type inheriting from GridColumnBase to implement a static CreateInstance() method. I can’t make CreateInstance a static abstract member of GridColumnBase, so how do I enforce that each class implement this method?

Edit: Thinking about this a little more I reached a conclution that CreateInstance() is not a feature of a class inhereting GridColumnBase, but is a feature of a class wanting to be included in the factory. Maybe I don’t need to enforce this on the base class level. Maybe I need to leave it to the implementing class to decide how it whishes to participate in the factory process, i.e. passing in to the factory any function it whishes to delegate.
Does this make sense to anyone but me? 🙂

  • 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-06-15T22:05:18+00:00Added an answer on June 15, 2026 at 10:05 pm

    I ended up opting for a smart use of reflection. To give credit where credit is due, I modified this solution http://www.matlus.com/high-performance-class-factory/ for my own needs.

    I think it’s a nice and elegant solution to the problem, and comparing results of our profiler, it does not degrade performance much.

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

Sidebar

Related Questions

I am in the process of creating a factory method which uses a generic
In some C++/CLI code I have a native class which has a factory method
I have a CustomerRelation class which has a method getInstance() and instance variable i.e
I'm using the Ninject Factory Extension and creating a custom instance provider explained in
I'm trying to register a factory method for creating instances of an open generic
What if I have few factory methods returning non-public type and pairing set of
I'm trying to create a JSF2 application which uses Spring3 for the DI and
I have a factory that is supposed to create objects that inherit from class
I have some simple code in which the main Thread is creating a new
I have a factory for creating containers based on ugly containers template<class T> std::vector<T>

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.