Hi,
This has to be a pretty common issue, and while we have answers, I'm trying to determine if there is any better way. We are using IoC / DI with structuremap. This means that our final application (an Asp.Net MVC 2 app) requires the presence of some assemblies which aren't being referenced anywhere else (our implemention of IReposi...
Should I register ViewModels in Container and resolve from there?
Benefits:
I can perform some actions when view model is activated
Container will inject dependencies for me
???
Drawbacks:
ViewModel lifetime management can be tricky:
if I make ViewModel singleton then I can't instantiate several controls of the same type
if I mak...
Hi,
i'm looking for a larger example of dependency injection and how it can be implemented. If class A depends on class B and passes a reference of class C to B's constructor, must not class A also take a reference to class C in it's constructor? This means that the main method in the application should create all classes really, which ...
I have an ASP.NET MVC2 application that supports visualization plug-ins/providers. The IVisualization interface is defined in a common assembly which is referenced by both the ASP.NET MVC2 app, and any visualization providers.
In the Visualization controller, I have a method which returns all the applicable visualizations for a given se...
Hi there,
does anyone have a good example of a boostrapper class i can see for reference..
I can't seem to find one anywhere, searched google but no luck.
Searched the helpfile and no luck..
Any help really appreciated
...
Hi there,
Can anyone help?
How do i registertype with the container where the type doesn't have NO PARAMETER constructor.
Infact my constructor accepts a string .. and i normally pass in a string that represents a Path.
So when i do resolve it automatically creates the new type but passing in a string?
Thanks in advance
...
Hi,
I am having problems when using dependency injection with Services in Grails.
class ExampleService{
def example2Service
def example3Service
def method1(){
def result = example2Service.method2()
}
}
class ExampleService{
def example3Service
def method2(){
def result = example3Service.metho...
I have an interface
public interface IResolver<T>
{
T Resolve();
}
I know this isn't the ideal (service locator is an anti-pattern and all), but in some cases it's still necessary (for example WCF service activation - I don't want to instantiate the channel until Resolve() is explicitly called...and in the case of BasicHTTP, the ...
I looked at this and it answers half my questions:
http://stackoverflow.com/questions/2370546/castle-windsor-register-class-with-internal-constructor
But can you use Windsor to use internal constructors/class along with dependency injection? (so constructor parameters get injected too)? I'd like to keep the class/constructor internal t...
I have some (sort of) Singletons which exist in three context:
Per AppDomain
Per HttpApplication
Per Web Request
Right now, I'm creating a child container per HttpApplication and another child per Web Request. This is necessary because some components SHOULD actually share singleton instances across the three layers. For security and...
Is it possible to wrap generic injections in some way?
Given the interface:
interface IFoo<T>
In my guice module:
bind((Key<IFoo<SomeType>) Key.get(Types.newParameterizedType(IFoo.class, SomeType.class))).to(Foo.class);
But before I return the Foo instance I want to wrap it with this:
class FooWrapper<T> implements IFoo<T> { public...
I'm using strongly typed views and autofac for Dependency Injection under ASP.NET MVC2 and I'm trying to get a common dynamic header via dependency injection. I.e. i want this to happen without the view having to be away of this content even existing and i was hoping to avoid static discovery of the container and manual resolution, but I...
I am doing the design of a small project where I didn't use programming against interfaces for all my classes. I found that some classes would hardly ever be needed to change, so I let them be referenced by their client classes as concrete classes.
So, let's say we have ClassB that'll be consumed be consumed by ClassA:
class ClassB {...
Hi Guys,
I'm relatively new to dependency injection, so I'm probably butchering the concept to some extent. However, I'm trying to achieve something like the following, but am unsure as to whether or not it's feasible:
Lets say I have two containers, each containing different instances of the same type of dependency. For example, each ...
I cant seem to find an answer on the internet anywhere.
So I have a processing project in Eclipse
I want to be able to access objects in my "main" class that extends PApplet in another class without having to pass them through the constructor. I am not the most experienced programmer so my terminology might be off but hopefully this ex...
Hi Guyz,
I am using Eclipse 3.6 and jboss 4.2
I've created Enterprise Application with two modules, EJB and WEB.
I have converted the WEB module into GWT application (and added necessary files - html and css)
The problem is, when I need to Inject either the Remote or Local interfaces in the GWTServiceImpl servlet using the @EJB annota...
Hi All,
I'm using my app.config to tell Unity my interface to type mappings...
<unity>
<containers>
<container>
<types>
<type type="UnityDAL.Interfaces.IDataContextFactory, UnityDAL"
mapTo="UnityDAL.UnityDemoDataContextFactory, UnityDAL" />
<type type="UnityDAL.Interfaces.IProductRepository, UnityDAL"
...
Hi,
Since I updated to ASP.NET MVC 3 Beta 1, I get a NullReferenceException whenever I call TryUpdateModel() during a unit test session.
The stack trace looks like this:
Execute
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Web.Mvc.JsonValueProviderFactory.GetValueProvider(Con...
I've been becoming more familiar with the Factory Pattern (along with Strategy Pattern) and what a great benefit the pattern can have. However, I've been struggling with the following situation:
Previously, I would have done something like the following, where there's a manager class that would build and save a Car. There's no depende...
I can't help but think there is a better way to do this than my current code within my StructureMap Registry.
For<ISchedulerFactory>().Use(() => new StdSchedulerFactory());
For<IScheduler>().Use(() => new StdSchedulerFactory().GetScheduler());
Is there a way to have it use the previous registered type and call the method from that...