Hi

Maby I misunderstod the manual, I got the impression that
"Container.Register(Component.For(models).LifeStyle.Transient); "
would register all types in the "models" array.

I changed my foreach loop to:
            foreach (Type model in models)
            {
                config.For(model).Add<NotifyPropertyChangedBehavior>
();
                Container.Register(Component.For
(model).LifeStyle.Transient);
            }


Then I have another problem in my test...

The line:

                ((INotifyPropertyChanged)model).PropertyChanged +=
                    (sender, e) =>
                    {
                        eventWasRaised = true;
                    };

will raise a Exception:  System.InvalidCastException: Unable to cast
object of type 'lgTronic.Infrastructure.Domain.Model.Person' to type
'System.ComponentModel.INotifyPropertyChanged'..

It seems like the event NotifyPropertyChangedEvent is missing.


//lasse


On 7 Nov, 20:23, José F. Romaniello <[email protected]> wrote:
> 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-unhaddinscompone...
>
> <http://jfromaniello.blogspot.com/2009/10/introducing-unhaddinscompone...>
>
> 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 -- 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to