예제 #1
0
        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);
            }
        }
예제 #2
0
        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);
        }
예제 #3
0
 public static void ClearDefaultEvents() => ReflectionCash.ClearDefaultEvents();
예제 #4
0
 public static void ClearDefaultEvent(Type type) => ReflectionCash.ClearDefaultEvent(type);
예제 #5
0
 public static bool SetDefaultEventIfNotExist(Type type, string eventName) => ReflectionCash.SetDefaultEventIfNotExist(type, eventName);
예제 #6
0
 public static void SetDefaultEvent(Type type, string eventName) => ReflectionCash.SetDefaultEvent(type, eventName);
예제 #7
0
 public static bool HasDefaultEvent(Type type) => ReflectionCash.HasDefaultEvent(type);