private static void MakeCallBack <T>(T service) where T : class, IManage { DeferredCallBack <IManage>[] deferredCallBacksCopy = new DeferredCallBack <IManage> [callBackDictionary[service.GetManageType()].Count]; callBackDictionary[service.GetManageType()].CopyTo(deferredCallBacksCopy); for (int i = 0; i < deferredCallBacksCopy.Length; i++) { deferredCallBacksCopy[i](service); } }
/// <summary> /// Function for set deferred call back to moment ready one of managers/services /// </summary> /// <typeparam name="T">Type of manager</typeparam> /// <param name="deferredCallBackInstance">Instance of callback function</param> public static void CreateDeferredCallBack <T>(DeferredCallBack <T> deferredCallBackInstance) where T : class, IManage { if (deferredCallBackInstance != null) { T service = GetService <T>(); if (service != null) { deferredCallBackInstance(service); return; } else { if (callBackDictionary.ContainsKey(typeof(T))) { callBackDictionary[typeof(T)].Add((DeferredCallBack <IManage>)(object) deferredCallBackInstance); return; } else { callBackDictionary.Add(typeof(T), new List <DeferredCallBack <IManage> >()); callBackDictionary[typeof(T)].Add((DeferredCallBack <IManage>)(object) deferredCallBackInstance); return; } } } else { Debugger.SetMessage("You try to create null callback. For manager " + typeof(T)); } }