private ComponentState AttachAndInitComponent(IComponent component, int parentComponentId) { var componentId = _nextComponentId++; var parentComponentState = GetOptionalComponentState(parentComponentId); var componentState = new ComponentState(this, componentId, component, parentComponentState); Log.InitializingComponent(_logger, componentState, parentComponentState); _componentStateById.Add(componentId, componentState); component.Attach(new RenderHandle(this, componentId)); return(componentState); }
public void AddComponent(IComponent component) { if (component.IsAttached) { throw new InvalidOperationException(Strings.ComponentAttached); } if (this.Components.ContainsKey(component.Name)) { throw new ArgumentException(Strings.DuplicateKey); } component.Attach(this); this.Components.Add(component.Name, component); this.UpdateSorting(); }