BlueCollar.MachineProxy.InvokeEventHandler C# (CSharp) Метод

InvokeEventHandler() приватный Метод

Invokes the event handler identified by the given method on the given instance.
private InvokeEventHandler ( object instance, MethodInfo method ) : void
instance object The instance to invoke the event handler on.
method System.Reflection.MethodInfo The method identifying the event handler to invoke.
Результат void
        private void InvokeEventHandler(object instance, MethodInfo method)
        {
            ParameterInfo[] args = method.GetParameters();

            switch (args.Length)
            {
                case 2:
                    method.Invoke(instance, new object[] { this, new EventArgs() });
                    break;
                case 1:
                    method.Invoke(instance, new object[] { this });
                    break;
                case 0:
                    method.Invoke(instance, null);
                    break;
                default:
                    throw new NotSupportedException(string.Format(CultureInfo.InvariantCulture, "The specified method was expected to have 0, 1, or 2 parameters: {0}", method.ToString()));
            }
        }