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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:51:02+00:00 2026-05-20T14:51:02+00:00

I using StructureMap to create instances of ModuleData I have many classes that inherit

  • 0

I using StructureMap to create instances of ModuleData

I have many classes that inherit from ModuleData(class A,B,C…) and each of them get Config1 or Config2 in coustructor
In Registry(located in file1.cs) I scan all types of ModuleData.

In Get(lacated in file2.cs) I get the instance.

I want that when ObjectFactory creates Config1/Config2 while creating instance of ModuleData it will pass “param” to Config1/Config2 constructors.
How I can configure structuremap to do this?

P.S. Registry & Get methods are located in different files!!!
Thank you

public class Config1
{
     Config1(string param)
     {
     }
}
public class Config2
{
     Config2(string param)
     {
     }
}
//.....//
public class A : ModuleData
{
    A(Config1 c)
   {
   }
}
public class B : ModuleData
{
    A(Config2 c)
   {
   }
}
//....//
//located in file1.cs
public Registry()
{
     Scan(x =>
     {
          x.TheCallingAssembly();
          x.AddAllTypesOf<ModuleData>();
     });            
     ObjectFactory.Initialize(x =>
     {
             x.For<Config1>().Use<Config1>();
             x.For<Config2>().Use<Config2>();
     });
}    
//....//
//located in file2.cs
public ModuleData Get(object o)
{
    var module = o as PageModule;
    var t = Type.GetType(string.Format("{0}.{1},{2}", Settings.Namespace, module.Name, Settings.Assembly));
    return ObjectFactory.With("param").EqualTo(module.Parameters).GetInstance(t) as ModuleData;
}
  • 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-20T14:51:03+00:00Added an answer on May 20, 2026 at 2:51 pm

    I can’t think of a good way to do what you want, I think its a bit of a design problem… I think you would have to explain a bit more about why you need to do this for me to help you.

    What is a page module? Why is your config objects dependent on it?

    Based on your comment, I think what you need is a factory object that creates ModuleData objects for you. Since they are objects it does not make much sense to get them from the container. Think about using a data access technology like Entity Framework, it would not make sense to get those objects from the container. From what I can tell, this is a similar case.

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

Sidebar

Related Questions

Using StructureMap, is it possible to have a singleton object for each value of
I'm trying to enable SqlCacheDependency through my StructureMap IoC, I'm using LinqToSql I have
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
I've been using StructureMap for sometime now but I'm far from an expert. My
I'm currently using StructureMap to inject instances of NHibernate ISessions using the following code:
I am building an asp.net MVC2 web app using StructureMap. I have created a
I am currently making the move from StructureMap to Castle Windsor. Using StructureMap, you
I have an ASP.Net MVC application and I am using StructureMap within MVC to
Using online interfaces to a version control system is a nice way to have
Using ASP.NET MVC there are situations (such as form submission) that may require a

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.