Where are you using the container to get your registered interfaces? Inside or outside the using block?
The property will automatically be populated when you ask unity for an ITransactionService. Its been a while since I used unity, but with ninject you have to add a [Inject] attribute on the property. There might be something similar for unity... Constructor dependencies are created automagically On Apr 13, 2013 12:21 AM, "David Rhys Jones" <[email protected]> wrote: > > I'm having a huge problem trying to get unity to work, I've spent a whole day fighting it and can't get anywhere. I've used Spring.Net for a long time and have no problems. > > This is my class. > > public class TransactionService : ITransactionService > > { > > [ > > Dependency] > > public ITransactionData TransactionData { get; set; } > > } > > And this is my Setup. > > using (var u = new UnityContainer()) > > { > > u.RegisterType<IConnection, Connection>() > > .Configure<InjectedMembers>() > > .ConfigureInjectionFor<Connection>(new InjectionProperty("ConnectionString", "Server=waihopar11-0125;Database=Spirit;Trusted_Connection=True;")); > > u.RegisterType<ITransactionService, TransactionService>() > > u.RegisterType<ITransactionData, MockTransactionData>("mock"); > > .Configure< > > InjectedMembers>() > > // This bit I don't know how to do. how do I set the "Mock" TransactionData on the TransactionService. > > // I Can't find any examples that work with Unity 2.0.. > > .ConfigureInjectionFor<TransactionService>(new InjectionProperty("TransactionData", ?????? ); > > Help! > > thanks. > > Davy, > > The US Congress voted Pizza sauce a vegetable. Don't even try to convince me of anything in the states is sane any more!
