public static void ExecuteMethod(object methodSource, string methodName, bool ignorExecute = false) { methodSource = methodSource ?? throw new NullReferenceException("Method source can not be null."); var action = ReflectionCash.GetDelegateWithoutParameter(methodSource.GetType(), methodName) ?? throw new InvalidOperationException($"Can not find method {methodName} in object of type {methodSource.GetType()}."); if (!ignorExecute) { action(methodSource); } }
public static EventInfo GetDefaultEvent(Type eventSource) { var e = _DefaultEvent.GetValue(eventSource, () => { var a = eventSource.GetCustomAttribute <System.ComponentModel.DefaultEventAttribute>() ?? throw new InvalidOperationException($"Type {eventSource.Name} does not own a default event."); return(ReflectionCash.GetEvent(eventSource, a.Name)); }); if (e == null) { e = GetEvents(eventSource).FirstOrDefault(); } return(e); }
public static void ClearDefaultEvents() => ReflectionCash.ClearDefaultEvents();
public static void ClearDefaultEvent(Type type) => ReflectionCash.ClearDefaultEvent(type);
public static bool SetDefaultEventIfNotExist(Type type, string eventName) => ReflectionCash.SetDefaultEventIfNotExist(type, eventName);
public static void SetDefaultEvent(Type type, string eventName) => ReflectionCash.SetDefaultEvent(type, eventName);
public static bool HasDefaultEvent(Type type) => ReflectionCash.HasDefaultEvent(type);