Beispiel #1
0
        private async Task DoCallback(object source, PluginActionEventArgs args)
        {
            if (Callback == null)
            {
                return;
            }

            args.PluginName = Name;

            await Callback.Invoke(source, args);
        }
Beispiel #2
0
        private async Task Callback(object source, PluginActionEventArgs args)
        {
            if (Host.ShuttingDown)
            {
                return;
            }

            switch (args.ActionType)
            {
            case PluginActionType.SignalTerminate:
                await OnTerminated(source, new OperationTerminatedEventArgs(source, "Terminate signaled."));

                break;

            case PluginActionType.RegisterMethod:
                if (!(args.Result is IAsyncComposition <T>))
                {
                    break;
                }

                Host.RegisterComposition((IAsyncComposition <T>)args.Result);
                break;

            case PluginActionType.SendMessage:
                if (!(args.Result is IrcCommandEventArgs))
                {
                    break;
                }

                await OnCommandReceived(source, (IrcCommandEventArgs)args.Result);

                break;

            case PluginActionType.Log:
                if (!(args.Result is string))
                {
                    break;
                }

                Log.Information((string)args.Result);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }