Stetic.CommandDescriptor.InvokeMethod C# (CSharp) Method

InvokeMethod() private method

private InvokeMethod ( object target, string name, object context, bool withContext ) : object
target object
name string
context object
withContext bool
return object
        object InvokeMethod(object target, string name, object context, bool withContext)
        {
            object ptarget;
            PropertyInfo prop = FindBoolProperty (target, out ptarget);
            if (prop != null) {
                prop.SetValue (ptarget, !(bool)prop.GetValue (ptarget, null), null);
                return null;
            }

            if (withContext) {
                MethodInfo metc = target.GetType().GetMethod (name, flags, null, new Type[] {typeof(Gtk.Widget)}, null);
                if (metc != null)
                    return metc.Invoke (target, new object[] { context });
            }

            MethodInfo met = target.GetType().GetMethod (name, flags, null, Type.EmptyTypes, null);
            if (met != null)
                return met.Invoke (target, new object[0]);

            throw new ArgumentException ("Invalid command or checker name. Method '" + name +"' not found in class '" + target.GetType() + "'");
        }