Exemplo n.º 1
0
        /*********
        ** Private methods
        *********/
        /// <summary>Get the mod name for a given event handler to display in performance monitoring reports.</summary>
        /// <param name="handler">The event handler.</param>
        private string GetModNameForPerformanceCounters(ManagedEventHandler <TEventArgs> handler)
        {
            IModMetadata mod = handler.SourceMod;

            return(mod.HasManifest()
                ? mod.Manifest.UniqueID
                : mod.DisplayName);
        }
Exemplo n.º 2
0
        /// <summary>Add an event handler.</summary>
        /// <param name="handler">The event handler.</param>
        /// <param name="mod">The mod which added the event handler.</param>
        public void Add(EventHandler <TEventArgs> handler, IModMetadata mod)
        {
            EventPriority priority       = handler.Method.GetCustomAttribute <EventPriorityAttribute>()?.Priority ?? EventPriority.Normal;
            var           managedHandler = new ManagedEventHandler <TEventArgs>(handler, this.RegistrationIndex++, priority, mod);

            this.Handlers.Add(managedHandler);
            this.CachedHandlers = null;
            this.HasNewHandlers = true;
        }
Exemplo n.º 3
0
 /// <summary>Log an exception from an event handler.</summary>
 /// <param name="handler">The event handler instance.</param>
 /// <param name="ex">The exception that was raised.</param>
 protected void LogError(ManagedEventHandler <TEventArgs> handler, Exception ex)
 {
     handler.SourceMod.LogAsMod($"This mod failed in the {this.EventName} event. Technical details: \n{ex.GetLogSummary()}", LogLevel.Error);
 }