internal static bool IsOverridden(DiscordClientService service, string name, params Type[] types) { var serviceType = service.GetType(); var method = serviceType.GetMethod(name, BindingFlags.Instance | BindingFlags.NonPublic, null, types, null); return(method != null && method.DeclaringType != null && method.DeclaringType != method.GetBaseDefinition().DeclaringType); }
private async ValueTask ExecuteAsync <TEventArgs>(Func <DiscordClientService, TEventArgs, ValueTask> factory, DiscordClientService service, TEventArgs e) { try { await factory(service, e).ConfigureAwait(false); } catch (Exception ex) { Logger.LogError(ex, "An exception occurred while executing {0}.{1}().", service.GetType().Name, "On" + e.GetType().Name.Replace("EventArgs", "")); } }
private static bool IsOverridden(DiscordClientService service, string name) { var method = service.GetType().GetMethod(name, BindingFlags.Instance | BindingFlags.NonPublic); return(method != null && method.DeclaringType != typeof(DiscordClientService)); }