/// <summary> /// Set new service/manager to public using /// </summary> /// <param name="baseManagerInstance">Instance of your service/manager</param> /// <returns>Success of fail</returns> public static bool SetService(IManage baseManagerInstance) { if (baseManagerInstance != null) { if (baseManagerInstance.GetType().IsClass) { if (baseManagers.Exists(x => x.GetManageType() == baseManagerInstance.GetManageType())) { Debugger.SetMessage("Manager, that you want to attach, already exist.\nManager type is " + baseManagerInstance.GetManageType().ToString()); return(false); } baseManagers.Add(baseManagerInstance); baseManagerInstance.SetRemovingFunc(() => { DeleteService(baseManagerInstance.GetManageType()); }); CheckCallbacks(baseManagerInstance.GetManageType()); return(true); } else { Debugger.SetMessage("Manager, that you want to attach, is not a class.\nManager type is " + baseManagerInstance.GetType().ToString()); return(false); } } Debugger.SetMessage("Manager, that you want to attach, is null.\nManager type is " + baseManagerInstance.GetType().ToString()); return(false); }
private static void CheckCallbacks(System.Type type) { if (callBackDictionary.ContainsKey(type)) { IManage service = GetService(type); if (service.IsReady) { MakeCallBack(service); } else { EventableDelegate anon = () => { }; anon = () => { CheckCallbacks(service.GetManageType()); service.RemoveListener(InstableEventType.onReady, anon); }; service.AddListener(InstableEventType.onReady, anon); } } }