/// <summary> /// Attempts to call the page method by name /// </summary> /// <param name="name">The name of the method to call</param> /// <remarks> /// In order to call the method a few things have to be true. /// 1) The method must be non-private and non-static /// 2) The method must be adornded with the QueryCallVisible attribute /// 3) The Call event must not return with the Cancel property true /// </remarks> private void TryCallMethod(String name) { MethodInfo method = page.GetType().GetMethod(name, BindingFlags.Instance | BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { Attribute attr = Attribute.GetCustomAttribute(method, typeof(QueryCallVisibleAttribute), true); if (attr != null) { QueryCallEventArgs e = new QueryCallEventArgs(name, false); OnCall(e); if (!e.Cancel) { currentMethod = name; method.Invoke(page, null); currentMethod = String.Empty; } } else { page.Trace.Write("QueryCall", "Attempted call to method '" + name + "', but that method does not have the QueryCallVisibleAttribute on it."); } } else { page.Trace.Write("QueryCall", "Attempted call to to method '" + name + "', but no method found."); } }
/// <summary> /// raises the Call event /// </summary> protected virtual void OnCall(QueryCallEventArgs e) { if (this.Call != null) { this.Call(this, e); } }