But models is a collection of types? I don't know why you do that, but ...... I meant, If you will do container.resolve<Person>, where do you register your entities? like:
Container.Register(Component.For<Person>()).. if you are using this way. Remember now there are three ways: http://jfromaniello.blogspot.com/2009/10/introducing-unhaddinscomponentbehaviors.html <http://jfromaniello.blogspot.com/2009/10/introducing-unhaddinscomponentbehaviors.html> 2009/11/7 LasseL <[email protected]> > > In the line: > > Container.Register(Component.For(models).LifeStyle.Transient); > > > //lasse > > > On 7 Nov, 19:32, José F. Romaniello <[email protected]> wrote: > > Where do you add your Models to the container? > > > > 2009/11/7 LasseL <[email protected]> > > > > > > > > > > > > > Hi > > > > > I am setting upp unit tests for my application,,,,, this is my > > > initiation of the tests... (run only once). > > > > > Container = new WindsorContainer(); > > > Container.AddFacility<OnCreateFacility>(); > > > Container.AddFacility<FactorySupportFacility>(); > > > > > Container.AddFacility<ComponentBehaviorsFacility>(); > > > > > var config = new BehaviorDictionary(); > > > > > var assm = Assembly.LoadFrom > > > ("lgTronic.Infrastructure.dll"); > > > models = assm.GetTypes().Where(t => t.IsClass && ! > > > t.IsAbstract && t.Namespace.EndsWith("Model")); > > > > > foreach (Type model in models) > > > { > > > config.For(model).Add<NotifyPropertyChangedBehavior> > > > (); > > > } > > > Container.Register(Component.For<IBehaviorStore>().Instance > > > (config)); > > > > > Container.Register(Component.For > > > (models).LifeStyle.Transient); > > > > > the variable property contains approximatly 13 models. > > > > > The first test looks like: > > > > > [TestMethod] > > > public void Check_Model() > > > { > > > var model = Container.Resolve<Person>(); > > > > > The variable models is a array containing 13 types(Init procedure). > > > The first one (index 0) is a type called PhoneNumber. > > > > > The test method (check model) first line,,, always throws a > > > exception,,, like > > > System.InvalidCastException: Unable to cast object of type > > > 'PhoneNumberProxy3aea8754b910421bb1a3ef8604f144c3' to type > > > 'lgTronic.Infrastructure.Domain.Model.Person'.. > > > > > This is exception is thrown regardless of wich of my 13 types I am > > > trying to create.. (in this case Person). > > > > > So,,what am I doing wrong ??? I been looking at my code .. without > > > seeing anything obvious fault (for me) > > > I am using the latest (r815) version of unAddons > > > > > //lasse- Dölj citerad text - > > > > - Visa citerad text - > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
