I'm running into an issue with Autofac2 and MVC2. The problem is that I am trying to resolve a series of dependencies where the root dependency is HttpRequestScoped. When I try to resolve my UnitOfWork (which is Disposable), Autofac fails because the internal disposer is trying to add the UnitOfWork object to an internal disposal list ...
Hi,
I want to assert that my registrations are valid, i.e no dependency is missing and there are no circular dependencies.
I'd like to do that in my application (and not in a unit-test) so I'd be able to fail-fast if the configuration is invalid.
I also want to accomplish that without resolving (and instantiating) all the components - on...
Hi,
I've just stumbled upon this:
within a Unity container, I want to register IDictionary<TK, TV>; assume that it's IDictionary<string, int>
_unityContainer = new UnityContainer()
.RegisterType<IDictionary<string, int>, Dictionary<string, int>>();
but if I try
var d = _unityContainer.Resolve<IDictionary<string, int>>();
it f...
I'm building an application which uses AutoFac 2 for DI. I've been reading that using a static IoCHelper (Service Locator) should be avoided.
IoCHelper.cs
public static class IoCHelper
{
private static AutofacDependencyResolver _resolver;
public static void InitializeWith(AutofacDependencyResolver resolver)
{
_res...
Hello, Guys.
I'm developing a application using MVP and I have a question about How inject my dependencis in my presenters class. Because my presente receve too an instance of the my view. I thought of create a viewbase and inside it I create my dependencies instances and inject it in my presenter instance. Could also have a HttpModule ...
I'm trying to execute an action on a resolved component before it is returned as a dependency to the application.
For example, with this graph:
public class Foo : IFoo { }
public class Bar {
IFoo _foo;
IBaz _baz;
public Bar(IFoo foo, IBaz baz) {
_foo = foo;
_baz = baz;
}
}
When I create an instance of IFoo, I want th...
Hello guys, I have a generic IRepository that has 2 constructors, one have none parameters, other has the datacontext as parameter.
I want to define to structuremap to aways in this case use the parameterless constructor.
I want a way to create a parameterless contructor, other solutions that I have seen, they create a new Datacontext a...
Hi
I am wondering what good simple IoC frameworks are there for asp.net mvc? that have good documentation and are just easy to get up and going.
Thanks
...
Hi.
I'm trying to get StructureMap to put a Castle.DynamicProxy around some of the objects it creates. I have used the EnrichWith-feature earlier, but I think RegisterInterception would suit me better in this case, since I use scanning.
The problem is that in the "Process(object target, IContext context)"-method, I can't find out which...
I've literally just started using the Unity Application Blocks Dependency Injection library from Microsoft, and I've come unstuck.
This is my IoC class that'll handle the instantiation of my concrete classes to their interface types (so I don't have to keep called Resolve on the IoC container each time I want a repository in my controll...
In the project I'm working on I have a StructureMap registry for the main web project and another registry for my integration tests. During some of the tests I wire up the web project's registry, so that I can get objects out of the container for testing.
In one case I want to be able to replace a default concrete type from the web reg...
I was wondering if it is possible to inject a particular ActionFilterAttribute implementation using a IoC container.
For example, imagine you create a TransactionAttribute class [Transaction]
You use this to decorate action which should be wrapped in a transaction in the persistence layer. But implementation details of the attribute w...
Hey guys, here's my setup
Castle Windsor is my container
NServiceBus is itself using it's own container internally, Spring by default
I'm implementing the PubSub config.
Ok, if I have my Bus.Publish happening within my IWantToRunAtStartup class, then everything is fine. As a test for example on Run() we can start a timer and it'll go...
I'm using a UserNamePasswordValidator in WCF along with Unity for my dependency injection, but since WCF creates the instance of the UserNamePasswordValidator, I cannot inject my container into the class. So how would one go about this?
The simplest solution I can think of is to create a static proxy/wrapper class around a static insta...
Given registered services:
builder.RegisterType<Foo1>().Named<IFoo>("one").As<IFoo>();
builder.RegisterType<Foo2>().Named<IFoo>("two").As<IFoo>();
builder.RegisterType<Foo3>().Named<IFoo>("three").As<IFoo>();
Can I retrieve named implementations of IFoo interface by injecting something like Func<string, IFoo> ?
public class SomeClass...
Hi
Im fairly new with DDD and Im trying to use IOC in order to loosen up my tightly coupled layers :)
My C# web application consists of a UI, domain and persistence layer. My persistence layer references my domain layer and contains my concrete repository implementations and nhibernate mappings. Currently my UI references my domain lay...
Consider the following example:
public interface ITask
{
void Execute();
}
public class LoggingTaskRunner : ITask
{
private readonly ITask _taskToDecorate;
private readonly MessageBuffer _messageBuffer;
public LoggingTaskRunner(ITask taskToDecorate, MessageBuffer messageBuffer)
{
_taskToDecorate = taskToDec...
I am building a set of class libraries that produce office open xml based reports and I am using a static Windsor IoC container.
My problem is that one possible entry point to the reporting system is via a web front end which means that the reporting systems static IoC Container is being shared amongst multiple web requests which causes...
I know that in StructureMap I can read from my *.config files (or files referenced by them), when I want to pass specific arguments to an object's constructor.
ForRequestedType<IConfiguration>()
.TheDefault.Is.OfConcreteType<SqlServerConfiguration>()
.WithCtorArg("db_server_address")
.Equa...
My first real-world Python project is to write a simple framework (or re-use/adapt an existing one) which can wrap small python scripts (which are used to gather custom data for a monitoring tool) with a "container" to handle boilerplate tasks like:
fetching a script's configuration from a file (and keeping that info up to date if the ...