Пример #1
0
        /// <summary>
        /// Run subscribed event handlers.
        /// </summary>
        /// <param name="argument">Main's argument parameter</param>
        /// <param name="updateSource">Main's updateSource</param>
        public void CallUpdateEventHandlers(string argument, UpdateType updateSource)
        {
            UpdateEventArgs Args = new UpdateEventArgs(argument, updateSource);

            // If you have a DRY way that doesn't involving updating a list on every call: send me an email 🤷
            None?.Invoke(this, Args);             // Always invoked
            if (updateSource.HasFlag(UpdateType.Terminal))
            {
                Terminal?.Invoke(this, Args);
            }
            if (updateSource.HasFlag(UpdateType.Trigger))
            {
                Trigger?.Invoke(this, Args);
            }
            if (updateSource.HasFlag(UpdateType.Mod))
            {
                Mod?.Invoke(this, Args);
            }
            if (updateSource.HasFlag(UpdateType.Script))
            {
                Script?.Invoke(this, Args);
            }
            if (updateSource.HasFlag(UpdateType.Update1))
            {
                Update1?.Invoke(this, Args);
            }
            if (updateSource.HasFlag(UpdateType.Update10))
            {
                Update10?.Invoke(this, Args);
            }
            if (updateSource.HasFlag(UpdateType.Update100))
            {
                Update100?.Invoke(this, Args);
            }
            if (updateSource.HasFlag(UpdateType.Once))
            {
                Once?.Invoke(this, Args);
            }
            if (updateSource.HasFlag(UpdateType.IGC))
            {
                IGC?.Invoke(this, Args);
            }

            foreach (
                KeyValuePair <EventHandler <UpdateEventArgs>, EventHandlerMeta> EH in
                Subscribers.Where(pair => (updateSource & pair.Value.TargetUpdateType) != 0 || pair.Value.TargetUpdateType == UpdateType.None))
            {
                EH.Key.Invoke(this, Args);
            }
        }