//component framework public void AddComponent(VisualComponent comp) { //dissalow multiple components if (!comp.AllowMultiple || !GetComponent(comp.Type)) { comp.AddComponent(this); components.Add(comp); } }
public VisualComponent AddComponent <T>() where T : VisualComponent { Type t = typeof(T); try { VisualComponent comp = (VisualComponent)(t.GetConstructors()[0]).Invoke(new object[] { }); comp.Type = t; comp.AddComponent(this); components.Add(comp); return(comp); } catch (Exception e) { logger.Error(e.Message, e.StackTrace); } return(null); }