/// <summary> /// Sets the container of this component. /// Note that the component is not added to the container here! Therefore, use MyComponentContainer.Add(...) method and it /// will in turn call this method. Actually, you should seldom have the need to call this method yourself. /// </summary> /// <param name="container">The new container of the component</param> public void SetContainer(MyComponentContainer container) { if (container == null) { OnBeforeRemovedFromContainer(); } m_container = container; var aggregate = this as IMyComponentAggregate; if (aggregate != null) { foreach (var child in aggregate.ChildList.Reader) { child.SetContainer(container); } } if (container != null) { OnAddedToContainer(); } }
public void AddComponent(MyComponentContainer container, MyComponentBase component) { m_components.Add(component); }