private void CreateComponent(CompBase compParent) { // Parent will exist foreach (ComponentDefinition compChildDef in _children) { CompBase child = null; if (compChildDef._comp != null) { child = compParent.FindChild(c => string.Equals(c.Name, compChildDef._comp.Name)); if (child == null) { child = compChildDef._comp; compParent.Add(child); //U.LogInfo("Added child {0}", child.Name); } else { child.Name = compChildDef._comp.Name; } } else { // Does the child exist? child = compParent.FindChild(c => c.Name == compChildDef.Name); if (child == null) { // Need to add it if (compChildDef.CompType == null) { throw new MCoreExceptionPopup("Missing Type for {0}", compChildDef.Name); } if (compChildDef._initParms == null || compChildDef._initParms.Length == 0) { throw new MCoreExceptionPopup("Missing name or initilaizer {0}", compChildDef.Name); } try { // Create it child = Activator.CreateInstance(compChildDef.CompType, compChildDef._initParms) as CompBase; compParent.Add(child); } catch (Exception ex) { throw new MCoreExceptionPopup(ex, "Problem loading dll for {0}", compChildDef.CompType.Name); } } else { child.Name = compChildDef.Name; } } compChildDef.CreateComponent(child); } }
private void RecurseCleanUpChild(CompBase child, CompBase readComp, eCleanUpMode cleanUpMode) { if (cleanUpMode == eCleanUpMode.None) { return; } if (readComp.ChildArray != null) { foreach (CompBase subChild in readComp.ChildArray) { CompBase foundChild = child.FindChild(subChild.Name); if (foundChild != null) { if (subChild.ChildArray != null) { if (cleanUpMode == eCleanUpMode.AllLayer) { RecurseCleanUpChild(foundChild, subChild, cleanUpMode); } } } else { readComp.Remove(subChild); } } } }
private void RecurseConstructChild(CompBase child, CompBase readComp) { if (child.ChildArray != null) { foreach (CompBase subChild in child.ChildArray) { CompBase foundChild = readComp.FindChild(subChild.Name); if (foundChild != null) { if (subChild.ChildArray != null) { RecurseConstructChild(subChild, foundChild); } } else { readComp.Add(subChild); } } } }