quick CompositeContainer.cs question (CTP)

Topics: CAB & Smart Client Software Factory
Sep 9, 2005 at 1:46 PM
originally posted by: acheven

Hi all, i am relatively new to the whole Component/Container IoC thingy and are currently studying implementation of CompositeContainer.

When looking at the code inside CompositeContainer.cs
@ public void Add(IComponent component, string name)

i do not understand the following bit:

if (Contains(component))
if (component.Site == null)
component.Site.Name = name;

If trying to add a component that already exists, why remove and then re-add it?

Is this bit left over from previous versions or am i missing the point?

Could anyone please explain why this is required?

Thanks a lot,
Sep 9, 2005 at 2:06 PM
originally posted by: acheven

also in the same file

@public void Remove(object item)

why wrap object and site it before removing it?