This project is read-only.

Understanding Containers

Topics: User Forum
Jan 26, 2007 at 3:34 PM
I am glad that you guys are working on an example for an MVP composition. For the time being, I have a question concerning the IContainer Add(andClear)Model methods:

Is the propertyBag argument simply a dynamic value object of a domain model object?

Example: I have a Store domain object. a Store contains and Address (street, city, state, zip) and a company name.
If I wanted to add a store item to the container would I need to create a dictionary that includes the
company name and the Address?

Jan 27, 2007 at 3:02 PM
Not really, since you can call it like this:

IContract xyz = AddView(new Dictionary<string,object>());
xyz.Property1 = anyValue;
//... set another properties

The propertybag is useful if you need some values before adding the view.

For instance, I have a view that has 3 placeholders, one for managers, one for developers and one for testers. So, before I insert the view I must know beforehand what the position for the member is. This way I do it like this:

Dictionary<string,object> props = new Dictionary<string,object>();
props.Add("Position", member.Position);
IMember m = AddView(props);

Then in my AddView method I do a switch for propertyBag"Position" casted to the enum type.

That´s the goal of PropertyBag. Values that you need before building the view.

Thanks a lot for your interest and keep questions coming since they add a lot to the framework.

Bernardo Heynemann
Jan 29, 2007 at 2:40 PM
Ok, that clarify's the purpose of the propertybag a lot. I am still a little hazy on the IContainer and IContainerItem purpose though. It It looks to me that the IContainer interface holds a collection of views, which are returned as IContainerItems when added. From my example in the other post, where I had a list of domain objects, you said the IContainer was used to manage such a list. But from appearances it seems that each view is referenced by different properties. This leads me to believe that the IContainer has one of two functions:

1) (this one seems least likely to me) Each domain object item in the list has its own view stored in the collection
(along with its own presenter),

2) (much more likely) a view in the container is set with an item from the list dynamically (through its presenter
no doubt and probably on a Click command in most cases)

Now option (1) makes little sense, since we would have to clone the same view (and presenter) for each item in the list, but I list it because of the other post you responded to, which made it sound like an IContainer holds a view version of a list of domain objects.

I could be way off on this. Keep up the great work!
Jan 30, 2007 at 1:49 AM
Gilligan I strongly advise you to download the source and take a look at the sample included which showcases the use of the container.

The container´s purpose is to dynamically create and hook presenters and views (yeah you got that right hehehe).

What I store in the viewState are just Keys to the views, so that I can recreate them dynamically in each postback with the same Id (so ASP.Net can maintain Viewstate). When I recreate the view no doubt I recreate the presenters and init and load them all (that´s why I provide the IsFirstCall parameter, so you can load only the first time for example).

I am very satisfied that you like the framework.
I´ve already started my book on the framework. It´ll be published by an US publisher and will cost between US$8,00-10,00, so I´m guessing people will be able to afford it hehehe. In the book I detail every single aspect of the framework with lots of samples. But even if you don´t want to buy the book, I´ll release FREE OF CHARGE the PDF version of it for download. :)

Any doubts, though, feel free to ask.

Bernardo Heynemann
Jan 30, 2007 at 1:51 PM
I will definitely take a look at the sample. Thank you.