I have two closely related applications that are both using the Unity IoC container. They have some custom types in common, but not all of them. At the moment I have two config files that have a lot of duplication. I'd like to have just one Unity config file to rule them all.
However, as not all types exist in both applications Unity i...
Using log4net we would like to log all calls to our ASP.NET MVC controller action methods.
The logs should include information about any parameters that were passed to the controller.
Rather than hand-coding this in each action method we hope to use an AoP approach with Interceptors via Unity.
We already have this working with some ot...
Hi All,
Having a bit of a headache with Unity XML configuration and generics. I have these files:
public interface IRepository<T> {}
public class OrderRepository : IRepository { }
public class DispatchOrderProcess
{
public DispatchOrderProcess(IRepository<Order> repository) { }
}
I would like to inject the Order Repository in...
I'm trying to configure log4net with Unity, but I don't think I fullu understand what needs to be done.
In particular I can't figure how to log the %thread such that it logs the name of the class.
I created a MyLog4Net : ILogger class, but I don't get how I pass this class the calling class and how this relates to the logger name in th...
I am a total newbie on Prism. I have been getting to understand a lot from questions on SO and from various Blogs. I am using latest build – V2
I want some explanations on things that may be pretty easy things for you guys but it’s just not getting into my brains (small one for that).
Instead of doing it all right the first time , for ...
When I
container.RegisterType<IInterface, MyClass>();
everything works, and all dependent properties annotated with:
[Dependency]
are resolved through the container.
But, I now have an int property that I'd like also to resolve through the container. It's not passed in the constructor, but just as a public property. So I tried ...
Hi!
This question is about Unity Container but I guess it is applicable to any dependency container.
I have two classes with circular dependencies:
class FirstClass
{
[Dependency]
public SecondClass Second { get; set; }
}
class SecondClass
{
public readonly FirstClass First;
public SecondClass(FirstClass first)
{...
Hi!
How to fill TODO to make this test pass?
class MyClass { }
[Test]
public void Singleton_by_default_test()
{
var parentContainer = GetUnityContainer();
var container = parentContainer.GetChildContainer();
// TODO: Add magic here (but do NOT explicitly register MyClass in container!)
Assert.AreSame(containe...
I am using the Unity IoC container, and I need to intercept any calls to Resolve for a certain base interface, and run my own custom code to construct those types.
In other words, in the sample code below, when I call container.Resolve<IFooN>(), if it hasn't got an instance of the concrete implementing type, it calls MyFactoryFunction ...
We are using unity to resolve the WCFService and the good practice of WCF says close the client once done.
But if we are using unity when and how to close WCFServiceClient?
Thanks
...
Hi all,
how do I register two different interfaces in Unity with the same instance...
Currently I am using
_container.RegisterType<EventService, EventService>(new ContainerControlledLifetimeManager());
_container.RegisterInstance<IEventService>(_container.Resolve<EventService>());
_container.RegisterInstance<IEve...
I want to use dependancy injection technique in my site. For that i want to choose either structuremap or unity application block. So which one is better and why we should use one of them?
...
My controllers now implement an interface and inject a repository implementation using the Unity framework. My question is, are these injected implementations singletons? Does that mean all of my users hitting the repository (from the controller) use the same instance?
...
I have .net classes
I am using unity as IOC for resolving our dependencies.
It tries to load all the dependencies at the beginning.
Is there a way (setting) in Unity which allows to load a dependency at runtime?
...
Hi,
Currently, I created my custom PerWebRequestLifetimeManager using HttpContext.Current.Items as backing store. I used that lifetime manager for Linq2Sql DataContext.
Eveything is working fine until I need to use Cache for storing data (for 5 min). After 5 min, I need to retrieve data from DB and put it into the Cache. To d...
I have a class in my Prism/CAL application which generates a form for users to fill in data.
The form is defined by an XML file like this:
<area idCode="general" title="General">
<column>
<group title="Customer Data">
<field idCode="title" requiredStatus="true">
<label>title</label>
...
Hi, I'm converting a Castle/Monorails application into a Unity/Asp.NET MVC one,
I'm stuck in trying to converting this component configuration:
<component
id="ComponentBaseConfiguration"
service="MyFakeNamespace.BOL.IConfiguration, MyFakeAppDll"
type="MyFakeNamespace.BOL.ConfigurableConfiguration, MyFakeAppDll">
<parameters>
...
Hi All,
I am using Unity DI container. In the config file I specify the following type as :
<type type="Interfaces.ILogger,Interfaces"
mapTo = "ConcreateClasses.ConsoleLogger,ConcreateClasses" />
My understanding is that both the Interfaces dll and ConcreteClasses dll should be referenced in my project in order for this to work.
B...
Is there a way to make Unit dispose property-injected objects as part of the Teardown?
The background is that I am working on an application that uses ASP.NET MVC 2, Unity and WCF. We have written our own MVC controller factory that uses unity to instantiate the controller and WCF proxies are injected using the [Dependency] attribute on...
I have a console application that uses Unity. In the app.config, I have 20 or so types registered in the default container.
I find that starting up the application (until I start to see some initial output) is very slow compared to a console application built without Unity.
Is there anyway I can improve this start up time?
...