public static IInputDispatcher LoadDispatcher(string DispatcherName) { if (s_dispatcher.ContainsKey(DispatcherName)) { throw new Exception(DispatcherName + " Dispatcher has exist!"); } Type typeArgument = Type.GetType("VFramework.Common." + DispatcherName); if (typeArgument == null) { throw new Exception(DispatcherName + " is not dont have class!"); } if (typeArgument.IsSubclassOf(typeof(IInputDispatcher))) { throw new Exception(DispatcherName + " is not IInputDispatcher subclass!"); } Type dispatcherClass = typeof(InputDispatcher <>); Type eventEventClass = dispatcherClass.MakeGenericType(typeArgument); IInputDispatcher Dispatcher = (IInputDispatcher)Activator.CreateInstance(eventEventClass); s_dispatcher.Add(DispatcherName, (IInputDispatcher)Dispatcher); Dispatcher.m_OnAllEventDispatch = s_OnEventDispatch; return(Dispatcher); }
public static void RemoveAllEventListener(string eventName, InputEventCallBack callback) { IInputDispatcher dispatcher = GetDispatcher(eventName); dispatcher.m_OnAllEventDispatch -= callback; }
public static void RemoveListener(string eventName, string eventKey, InputEventHandle <IInputEventBase> callback) { IInputDispatcher dispatcher = GetDispatcher(eventName); dispatcher.RemoveListener(eventKey, callback); }
public static void Dispatch(string eventName, IInputEventBase inputEvent) { IInputDispatcher dispatcher = GetDispatcher("VFramework.Common." + eventName); dispatcher.Dispatch(inputEvent); }