Is anyone out there using the Prism framework with Ninject instead of Unity? I need some functionality Unity isn't supporting yet, and I've decided to switch the IoC container to Ninject. I'm struggling a bit with the replace though..
What I need to use from Prism is the EventAggregator and the RegionManager. I have seen this sample th...
From what I understand IServiceLocator is an interface to abstract the actual IoC container away? I'm asking with relation to Prism where I'm trying to replace Unity with Prism, and I see Prism-classes relying on IServiceLocator. Could someone please clarify the role of the interface and when it is used?
And also; what is the Common Se...
I'm working on replacing Unity with Ninject in the Prism framework. This requires me to implement a Ninject specific IServiceLocator. From what I've understood I can inherit the ServiceLocatorImplBase instead, so that's what I do. Now how can I set this to be the Current ServiceLocator? I need this in order to have e.g. the RegionManager...
DISCLAIMER: I know there is debate between DI and service locator patterns. I have a question that is intended to avoid the debate. This question is for the service locator fans, who happen to think like Fowler "DI...is hard to understand...on the whole I prefer to avoid it unless I need it." For the purposes of my question, I must av...
It was recommended to me that, when using an IOC container, I should change this:
class Foobar: IFoobar, IDisposable {};
Into this:
interface IFoobar: IDisposable{};
class Foobar : IFoobar{};
I'm wondering if this is ok, or if it solves one problem and creates another. It certainly solves the problem where I badly want to do this:...
UPDATE
As I've tried to get MEF working throughout my application, I'm coming across more an more places where I just don't get why it's not automatically creating my library when I expect it to. I think it all comes back to what Reed was saying about needing MEF to create everything. So right now, I have an XML reader class that need...
For the purpose of this discussion, there are two kinds of parameters an object constructor might take: state dependency or service dependency. Supplying a service dependency with an IOC container is easy: DI takes over. But in contrast, state dependencies are usually only known to the client. That is, the object requestor.
It turns ...
At my level of experience with Unity it might be faster to ask whether the "generics handling" bug acknowledged by ctavares back in 2008 was fixed in a public release.
Here was the problem (which might be my problem today):
Hi,
I get an exception when using ....
container.RegisterType(typeof(IDictionary<,>),
typeof(Dicti...
How should the configuration for an IoC container be organized? I know that registering by code should be placed at the highest level in an application, but what if an application had hundreds of dependencies that need to be registered? Same with XML configurations. I know that you can split up the XML configurations into multiple fil...
When I try to do this:
[Export(typeof(IMyService))]
[PartCreationPolicy(CreationPolicy.Shared)]
private MyService Service
{
get
{
var service = new MyService();
service.Configure();
return service;
}
}
I get a compile error: Attribute 'PartCreationPolicy' is not valid on this declaration type. It is...
When using Ninjects ConstructorArgument you can specify the exact value to inject to specific parameters. Why can't this value be null, or how can I make it work? Maybe it's not something you'd like to do, but I want to use it in my unit tests.. Example:
public class Ninja
{
private readonly IWeapon _weapon;
public Ninja(IWeapo...
I have a WPF application which I am using to learn MVVM and IoC.
The problem is that the Model used by one of the Views expects to pull one of its dependancies in the constructor from an IoC container.
When working on this View in the Visual Studio designer it cannot show the design because an exception is being raised in the model.
...
This is sort of a continuation of one of my earlier posts, which involves the resolving of modules in my WPF application. This question is specifically related to the effect of interdependencies of modules and the method of constructing those modules (i.e. via MEF or through new) on MEF's ability to resolve relationships.
First of all,...
I'm trying to resolve the AccountController in my application, but it seems that I have a lifetime scoping issue.
builder.Register(c => new MyDataContext(connectionString)).As<IDatabase>().HttpRequestScoped();
builder.Register(c => new UnitOfWork(c.Resolve<IDatabase>())).As<IUnitOfWork>().HttpRequestScoped();
builder.Register(c => new...
If a program has literally just deserialized an object (doesn't really matter how, but just say BinaryFormatter was used).
What is a good design to use for re-injecting the dependencies of this object?
Is there a common pattern for this?
I suppose I would need to wrap the Deserialize() method up to act as a factory inside the containe...
Hi,
Background - I'm looking to create a reusable library that allows one to work with a topology map of data. That is data that consists of nodes and relationships between them. The API's would include methods such as "find all children" for which the method would have to "walk the tree" and find all the nodes under this one etc. The...
Hi,
Q1 If I have a reusable library that is available, that uses interfaces with classes that use the getInstance concept to create concrete classes for you to use, then in this case would that make sense on the client side to use the IOC container to create instances of these classes? Or is that really applying a double layer of abst...
Hello, I meet one problem that i can't solve now.
I have the following:
UnityHelper.DefaultContainer.RegisterInstance(typeof(IMyInterface), "test", instance);
where UnityHelper.DefaultContainer is my helper for getting unity container with loaded configuration.
here I registered instance as an instance of IMyInterface.
So anywhere(so...
I'm trying to get structuremap to build Fluent Nhibernate's SessionSource object for some of my intregration tests. The only problem is that Fluent's concrete implementation of ISessionSource (SessionSource) has 3 constructors:
public SessionSource(PersistenceModel model)
{
Initialize(new Configuration().Configure(), m...
I am using structuremap in my project. To inject different implementation of a repository, I want to have a switch in app.config which changes all real implementation of a repository to a mock repositories.
Lets say IRepository has two implementations RealRepository and MockRepository
ForRequestedType()
.TheDefaultIsCon...