public void Remove <T>() where T : ICompose { System.Type type = typeof(T); ICompose module = null; if (mModuleDys.TryGetValue(type, out module)) { mModuleLts.Remove(module); mModuleDys.Remove(type); module.OnRemove(); } }
public void Remove <T>() where T : ICompose { if (m_Dispose) { return; } ICompose compose = Find <T>(); if (compose != null) { m_Composes.Remove(compose); compose.OnRemove(); } }
public T Add <T>() where T : ICompose, new() { if (m_Dispose) { return(default(T)); } ICompose compose = Find <T>(); if (compose == null) { compose = new T(); m_Composes.Add(compose); compose.OnInit(); } return((T)compose); }
/* 这里使用TryGetValue而不用ContainsKey,更方便之后对compose进行OnRemove * Remove的同时组件的Remove也要被触发 */ public void Remove <T>() where T : ICompose { System.Type type = typeof(T); if (debug) { Debug.Log("game manager remove " + type.Name); } ICompose compose = null; if (composeDict.TryGetValue(type, out compose)) { composeDict.Remove(type); composeList.Remove(compose); compose.OnRemove(); } }
public Dictionary <string, string> Orchestrate(ComposeInstructions instructions) { var composition = new Dictionary <string, string>(); var validation = inputValidator.Validate(ref instructions); if (!validation.isValid) { return(composition); } composer = composerFactory.Build(instructions.Mode); composition = composer.Compose(instructions); return(composition); }
private ICompose Find <T>() where T : ICompose { Type t = typeof(T); ICompose compose = null; int length = m_Composes.Count; for (int i = 0; i < length; ++i) { ICompose c = m_Composes[i]; if (c.GetType() == t) { compose = c; break; } } return(compose); }