コード例 #1
0
 public static void InvokeStaticEvent()
 {
     StaticEvent?.Invoke();
 }
コード例 #2
0
 public static void StaticFireEvent(short arg)
 {
     StaticEvent?.Invoke(typeof(StaticTestClass), new TestEventArgs <short> {
         Arg = arg
     });
 }
コード例 #3
0
 public static void RaiseStaticEvent(EventArgs eventArgs)
 {
     StaticEvent?.Invoke(null, eventArgs);
 }
コード例 #4
0
 public void TestStaticEventInvoke()
 {
     StaticEvent += EventHandler;
     StaticEvent.Invoke();
 }
コード例 #5
0
 public static void RaiseStaticEvent()
 {
     StaticEvent?.Invoke(null, new ViewModelClosedEventArgs(new TestViewModel(), true));
 }
コード例 #6
0
 public void InvokeOnButton()
 {
     StaticEvent.Invoke();
     StandartEvent = StandartEvents.ForStandartEvent.StandartEvent;
     StandartEvent.Invoke();
 }
コード例 #7
0
ファイル: Entry.cs プロジェクト: Corecii/ServerMod
        private void Chat_MessageSent(ChatSubmitMessage.Data messageData)
        {
            // by doing the below instead, we preserver formatting symbols.
            string message = UIExInputGeneric <string> .current_.Value_; //messageData.message_;

            var commandInfo = MessageUtilities.getCommandInfo(message);
            Cmd cmd         = commandInfo.matches ? Cmd.all.getCommand(commandInfo.commandName) : null;

            string logMessage = "";

            var client = GeneralUtilities.localClient();

            var showRegularChat = (!commandInfo.local && !GeneralUtilities.isHost()) || !LogCmd.localHostCommands ||
                                  !commandInfo.matches || commandInfo.forceVisible || (cmd != null && client != null && cmd.showChatPublic(client));

            if (showRegularChat)
            {
                sendingLocalChat = true;
                replicateLocalChatFunc?.Invoke(messageData);
                if (!commandInfo.matches)
                {
                    return;
                }
                logMessage = message;
            }

            if (client == null)
            {
                Console.WriteLine("Error: Local client can't be found !");
                return;
            }

            if (!showRegularChat)
            {
                MessageUtilities.sendMessage(client, $"[00FFFF]{message}[-]");
                logMessage = $"[00FFFF]{message}[-]";
            }

            MessageStateOptionLog cmdLog = new MessageStateOptionLog(new List <string>());

            MessageUtilities.pushMessageOption(cmdLog);

            if (LogCmd.localHostResults)
            {
                MessageUtilities.pushMessageOption(new MessageStateOptionPlayer(client));
            }
            else
            {
                MessageUtilities.pushMessageOption(new MessageStateOptionPlayer());
            }

            if (!commandInfo.local && commandInfo.commandName.ToLower() == "plugin")
            {
                printClient();
                LogCmd.AddLog(client, logMessage, cmdLog.GetLogString());
                MessageUtilities.popMessageOptions(2);
                return;
            }

            if (GeneralUtilities.isHost() && commandInfo.local)
            {
                MessageUtilities.sendMessage(client, "Cannot use local commands as host");
                LogCmd.AddLog(client, logMessage, cmdLog.GetLogString());
                MessageUtilities.popMessageOptions(2);
                return;
            }
            else if (!GeneralUtilities.isHost() && !commandInfo.local)
            {
                MessageUtilities.popMessageOptions(2);
                return;
            }

            if (cmd == null)
            {
                MessageUtilities.sendMessage(client, "The command '" + commandInfo.commandName + "' doesn't exist.");
                LogCmd.AddLog(client, logMessage, cmdLog.GetLogString());
                MessageUtilities.popMessageOptions(2);
                return;
            }

            if (commandInfo.local && !cmd.canUseLocal && cmd.perm != PermType.LOCAL)
            {
                MessageUtilities.sendMessage(client, "You can't use that command as client");
                LogCmd.AddLog(client, logMessage, cmdLog.GetLogString());
                MessageUtilities.popMessageOptions(2);
                return;
            }

            MessageUtilities.popMessageOptions();                                       // remove local/non-local only option

            bool renderToPublic = commandInfo.forceVisible || !LogCmd.localHostResults; // log settings may change if cmd changes them

            if (renderToPublic)
            {
                MessageUtilities.pushMessageOption(new MessageStateOptionPlayer());
            }
            exec(cmd, client, commandInfo.commandParams);
            if (renderToPublic)
            {
                MessageUtilities.popMessageOptions();
            }
            LogCmd.AddLog(client, logMessage, cmdLog.GetLogString());
            MessageUtilities.popAllMessageOptions();
        }