I have a WPF UserControl that I'd like to inject dependencies into. What's the best way to do this with Ninject?
To take a concrete example: I have a UserControl called MapView, and I want to inject an instance of my IDialogueService into it, via either constructor or property injection. Currently, I'm not using any dependency injection...
I've taken the plunge and used Guice for my latest project. Overall impressions are good, but I've hit an issue that I can't quite get my head around.
Background: It's a Java6 application that accepts commands over a network, parses those commands, and then uses them to modify some internal data structures. It's a simulator for some har...
In my prism application I'm getting the error Activation error occured while trying to get instance of type CustomerModule, key \"\".
It's caused by the fact that my customers module I'm trying to inject a "menuManager" of type IMenuManager:
namespace CustomerModule
{
public class CustomerModule : IModule
{
private rea...
I'm using Prism and Unity.
I've got this bootstrapper:
protected override IModuleCatalog GetModuleCatalog()
{
ModuleCatalog catalog = new ModuleCatalog()
.AddModule(typeof(CustomerModule.CustomerModule))
.AddModule(typeof(EmployeesModule.EmployeesModule))
.AddModule(typeof(MenuModule.MenuModule));
return...
I would like to inject ILog into my classes, not an ILoggerFactoryAdapter, but the ILoggerFactoryAdapter needs the name of the calling class (the class that wants to log something, so i can be properly categorized) so can Autofac somehow identify the class which are requesting the ILog and automaticly create the ILog from the factory?
...
FIXED: I'm leaving this in case some other Joe Schmo needs it.
In the controller factory you need to register the controller so that it can be found when called. container.Kernel.AddComponent("ExternalResources", typeof(InteSoft.Web.ExternalResourceLoader.ExternalResourceController), LifestyleType.Transient); Do it like so:
// Instanti...
I am fairly new to the MVP and the Entity Framework world so bear with me.
I currently have a View + Presenter combination, the view has two events Edit and Delete and the presenter just listens for these events. I also have a service object and repositories set up. The service layer takes some repository implementations which take an...
Following up on using dependency injection for WCF services, is there any way of using DI for WCF validators, so that one could do this:
public class DIValidator : UserNamePasswordValidator
{
private readonly IService service;
[Inject]
public DIValidator(IService service)
{
this.service = service;
}
pub...
In Ninject's dependency injection, if you set up a binding of a class to itself like so:
Bind<SomeClass>().ToSelf();
Ninject very nicely resolves any dependencies SomeClass has and gives you the object back. I want to be able to do something to the SomeClass it returns every time it creates a new one, so like a post-processing event....
I am looking for a way to do the following:
A Project :
Defines an abstract class that is called when some events happen (event handler if you will)
Defines the engine that will fire the events using the event handler above
B Project:
Defines the implementation for the abstract class
Runs the engine.
How can i register the implementa...
I am planning out some work to introduce Dependency Injection into what is currently a large monolithic library in an attempt to make the library easier to unit-test, easier to understand, and possibly more flexible as a bonus.
I have decided to use NInject, and I really like Nate's motto of 'do one thing, do it well' (paraphrased), and...
In a Composite Application (Prism), when my module loads, I get this error:
{"The current build operation (build
key Build
Key[CustomersModul.ViewModels.CustomerAllViewModel,
null]) failed: The parameter view
could not be resolved when attempting
to call constructor
CustomersModul.ViewModels.CustomerAllViewModel(Customers...
If I have an entity EntityA, which is an Entity Framework object, how would I go about injecting different behavior at time of creation?
These particular entities need to utilize a different strategy for some calculations. I would like to use DI to supply the correct strategy when the object is created. Is there any way to intercept?
A...
In asp.net MVC dependancy injection with controllers is simple and straightforward. Now, I'd like to remove most of the logic from views by using helpers. The problem is that these helpers use some of the objects that are injected.
Let me write an example:
public interface ISessionData
{
List<string> IdList {get;}
}
public MyContro...
I recently posted a question regarding a way to define the implementation of an abstract service on the client side.
dfa mentioned java.util.ServiceLoader as a solution for my problem.
I ended up going in a similar way, though not using ServiceLoader directly, mainly because i was using JDK 5. But another SOer jut went into panic when...
Hi.
When writing code in Java, it is very helpful to embrace composition and dependency injection to make it possible and easy to do pure unit testing by mocking collaborating objects.
I find that doing the same in Erlang is less straightforward and makes for dirtier code.
That's likely to be my fault, as I'm quite new to Erlang and q...
Is it possible for a ASPX view (in ASP.NET MVC) to have non-default constructor AND use this constructor when creating this view?
Example - Page will inherit from this class:
public class ViewPageWithHelper<TModel> : System.Web.Mvc.ViewPage<TModel> where TModel : class
{
public ViewPageWithHelper(Helpers helpers)
{
...
Can't get my head around the parameter passing in Autofac, the following code doesn't work:
class Config {
public Config(IDictionary<string, string> conf) {}
}
class Consumer {
public Consumer(Config config) {}
}
void Main()
{
var builder = new Autofac.Builder.ContainerBuilder();
builder.Register<Config>();
builder...
On a bit of a learning curve. Know one of you gurus can help me out.
I'm looking into SubSonic (SimpleRepository) and StructureMap. Really trying to get my head around them both.
I want to use SimpleRepository for the ease of use and letting my models define the database rather than pull off of or create a DB structure initially.
I ...
On this AutoFac "Best Practices" page (http://code.google.com/p/autofac/wiki/BestPractices), they say:
Don't Pass the Container Around
Giving components access to the container, or storing it in a public static property, or making functions like Resolve() available on a global 'IoC' class defeats the purpose of using dependency injectio...