Hi everybody)
I'm using Unity App Block for my project (version 1.2.0.0).
I have a problem with Unity Container BuildUp method which I'm using for my ascx controls. Here is some code (that's pretty simple)
public class BaseUserControl<T>:UserControl where T:class
{
protected override void OnInit(EventArgs e)
{
I...
Hi there,
With some kindly help from StackOverflow, I've got Unity Framework to create my chained dependencies, including an Entity Framework datacontext object:
using (IUnityContainer container = new UnityContainer())
{
container.RegisterType<IMeterView, Meter>();
container.RegisterType<IUnitOfWork, CommunergySQLiteEntities>(n...
Given a class with several constructors - how can I tell Resolve which constructor to use?
Consider the following example class:
public class Foo
{
public Foo() { }
public Foo(IBar bar)
{
Bar = bar;
}
public Foo(string name, IBar bar)
{
Bar = bar;
Name = name;
}
public IBar Bar ...
Is there any equivalent to the Registry class from StructureMap in Unity?
I like to think about a layer/component/library to configure it self - thus populating the container. So the "parent" layer will just need to know about the Registration class.
...
I have a MessageHandler with a dependency declared as:
public IRepository<Person> PersonRepository {get;set;}
I set up my Unity container with:
IUnityContainer container = new UnityContainer();
container.AddNewExtension<Interception>();
container.RegisterType(typeof(IRepository<Person>), typeof(Example.Data.InMemory.Repository<Perso...
I just started using the Unity Application Block to try to decouple my classes and make it easier for unit testing. I ran into a problem though that I'm not sure how to get around. Looked through the documentation and did some Googling but I'm coming up dry. Here's the situation:
I have a facade-type class which is a chat bot. It is a s...
Hello!
I have UnityContainer in my app yet. Now I want to add use of PRISM to my app and I want PRISM to use my Container instead of its inner one defined in bootstrapper. Or I would also satisfied if I could create some kind of link between these two containers in order when I call MyContainer.Resolve() it could redirect this call to P...
I'm trying to hock up WCF with dependecy injection. All the examples that I have found is based on the assumptions that you either uses a .svc (ServiceHostFactory) service or uses app.config to configure the container. Other examples is also based on that the container is passed around to the classes.
I would like a solution where the ...
Hi guys, i am in big dilema..
I am working on highly modular web app in ASP.NET MVC 2 (in fact, core will be super lightweight, all work on modules/plugins). I found MEF pretty useful for modules discovery, but i dont want to us it as IoC container. There is pretty good chance that I will need advanced features of "true" IoC container, s...
Castle Windsor facilities allow you to hook up some custom code that runs whenever components are registered. Does Unity have an equivalent?
...
All the examples I can find for the Unity InterfaceInterceptor require you to use Attributes to hook-up an ICallHandler to an artifact that you want to intercept. Is it possible to use an InterfaceInterceptor without needing to declare attributes so for example I can apply the interception to all classes?
...
I need to split my unity configuration into n different files so i can select it some of those files into the same unity container??
...
When I attempt to instantiate my instance of the base class I get the error:
a ResolutionFailedException with roughly the following error "The parameter host could not be resolved when attempting to call constructor"
I'm currently not using an Interface for the base type and my instance of the class is inheriting the base type class. ...
Question
Is it posible to have the Validation.Validate() method of the Validation Application Block see each parameter of the IParameterCollection supplied by Unity as my custom UserModel?
Background:
I am attempting to use both Unity and the Validation Application Block to validate method parameters.
I would like to be able to d...
My team is in the process of developing a system where we're using Unity as our IoC container; and to provide NHibernate ISessions (Units of work) over each HTTP Request, we're using Unity's ChildContainer feature to create a child container for each request, and sticking the ISession in there.
We arrived at this approach after trying o...
Hi,
I have a sub-class of DelegateCommand which fails with an InvalidProgramException, "The Command Language Runtime detected an invalid program." when I call Execute.
My sub-class looks like this:
public class SaveOrderCommand : DelegateCommand<IOrder>
{
[Dependency]
public IOrderService OrderService { get; set; }
p...
I am using Unity with MVC and NHibernate. Unfortunately, our UnitOfWork resides in a different .dll and it doesn't have a default empty .ctor.
This is what I do to register NHibernate:
var connectionString = ConfigurationManager.ConnectionStrings
["jobManagerConnection"].ConnectionString;
var assemblyMap = ConfigurationManager.AppSe...
I'm somewhat new to Unity and dependency injection. I'm trying to write a unit test that goes something like this:
[Test]
public void Test()
{
UnityContainer container = new UnityContainer();
DynamicMock myMock = new DynamicMock(typeof(IMyInterface));
container.RegisterInstance(typeof(IMyInterface), myMock.MockInstance); //...
I'm doing shared hosting with GoDaddy and I developed a sample ASP.NET MVC app using Castle Windsor and unfortunately, it didn't work in a medium trust setting. Specifically, I got this error: "[SecurityException: That assembly does not allow partially trusted callers"... etc. GoDaddy is sadly not flexible in their trust policy.
I'm not...
Hi,
My interface definition is:
public interface IInterface where T:UserControl
My class definition is:
public partial class App1Control : UserControl, IInterface
The unity section of my app.config looks as below:
<unity>
<typeAliases>
<typeAlias alias="singleton" type="Microsoft.Practices.Unity.Contai...