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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:33:18+00:00 2026-05-29T18:33:18+00:00

I have helper component used in multiple classes. This is typical scenario: public class

  • 0

I have helper component used in multiple classes. This is typical scenario:

public class HelperComponent 
{
    public void HelperMethod() 
    {
        // do something
    }
}

public class MyClass 
{
    private static HelperComponent Helper{ get; set;}

    public void Method1() 
    {
        Helper.HelperMethod();
    }
}

usage: new MyClass().Method1();

I would like to know what is advised spring.net configuration/solution for this configuration?
Initially I used this line to fetch helper component:

ContextRegistry.GetContext().GetObject("HelperComponentName")

Then I read that this isn’t preferable solution and that I should use injection in order to avoid dependency to spring and have transparent component usage.

My question is: how can I achieve this using spring configuration?

Can I inject static property into class? Or should I make Helper instance property?
If I convert Helper to instance property, do I need to define MyClass in spring configuration and use CreateObject to instantiate MyClass?
If yes, it isn’t satisfiable solution for me beacuse I would like to instantiate MyClass as written above.

Any help appreciated.

  • 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-29T18:33:19+00:00Added an answer on May 29, 2026 at 6:33 pm

    I’m not that familiar with spring, but when using an IOC container, you usually register all of your application’s dependencies (and their life cycles) and then resolve the ‘entry-point’ object at the top of the object graph.

    This allows you to take advantage of features of the IOC container like constructor and property injection.

    Once you are set up like this, you can manage the individual objects life cycles through the IOC containers configuration.

    In this case, I would inject HelperComponent in the constructor of MyClass after registering the HelperComponent as a singleton in the IOC container configuration.

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

Sidebar

Related Questions

I have a helper class pulling a string from an XML file. That string
I have a helper class that is just a bunch of static methods and
I have a rails helper in my application_helper.rb file that looks like this: def
I have implemented Nick's Facebook Plugin. Have Imported the Facebook Helper and Connect Component
I have a helper method 'default_content_for' which can be used to provide default content
I have some data/helper classes defined which I use in several projects. These data
I have a helper function, which basically calls CompareTo on two objects, but does
I have a helper assembly which includes a function to identify object types: namespace
I have a few 'helper' style extension methods I use quite regularly now (they
I have a Browser Helper Object project in c# that (obviously) references shdocvw.dll. I

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.