コード例 #1
0
        public Interpreter(IConveyor c)
        {
            this.Conveyor = c;

            // Reflect over all of the IHashCommands that are available.
            var type  = typeof(IHashCommand);
            var types = AppDomain.CurrentDomain.GetAssemblies()
                        .SelectMany(x => x.GetTypes())
                        .Where(x => type.IsAssignableFrom(x) && !x.IsInterface && !x.IsAbstract);

            foreach (var t in types)
            {
                var cmd = (IHashCommand)Activator.CreateInstance(t, this);
                HashCommands.Add(cmd);
            }
        }
コード例 #2
0
        public Interpreter()
        {
            this.Conveyor = AppServices.GetService <Conveyor>();

            // Reflect over all of the IHashCommands that are available.
            var type  = typeof(IHashCommand);
            var types = AppDomain.CurrentDomain.GetAssemblies()
                        .SelectMany(x => x.GetTypes())
                        .Where(x => type.IsAssignableFrom(x) && !x.IsInterface && !x.IsAbstract);

            foreach (var t in types)
            {
                var cmd = (IHashCommand)Activator.CreateInstance(t, this);
                HashCommands.Add(cmd);
            }

            // Setup the scripting environment.  Error handlers are set here allowing the actual scripting
            // environment to stay generic while the client worries about the implementation details.
            _scriptCommands    = new ScriptCommands(this);
            _winScriptCommands = new WindowScriptCommands(this);

            this.MoonSharpInit();
        }
コード例 #3
0
 public Task <string[]> HKeysAsync(string key) => MultiAsync(HashCommands.HKeys(key));
コード例 #4
0
 public string[] HKeys(string key) => Multi(HashCommands.HKeys(key));
コード例 #5
0
 public Task <double?> HIncrByFloatAsync(string key, string field, double increment) => MultiAsync(HashCommands.HIncrByFloat(key, field, increment));
コード例 #6
0
 public Task <bool> HSetNxAsync(string key, string field, object value) => MultiAsync(HashCommands.HSetNx(key, field, value));
コード例 #7
0
 public Task <string> HMSetAsync(string key, Dictionary <string, string> dict) => MultiAsync(HashCommands.HMSet(key, dict));
コード例 #8
0
 public string[] HMGet(string key, params string[] fields) => Multi(HashCommands.HMGet(key, fields));
コード例 #9
0
 public Dictionary <string, string> HGetAll(string key) => Multi(HashCommands.HGetAll(key));
コード例 #10
0
 public Task <string> HGetAsync(string key, string field) => MultiAsync(HashCommands.HGet(key, field));
コード例 #11
0
 public string HGet(string key, string field) => Multi(HashCommands.HGet(key, field));
コード例 #12
0
 public Task <bool> HExistsAsync(string key, string field) => MultiAsync(HashCommands.HExists(key, field));
コード例 #13
0
 public bool HExists(string key, string field) => Multi(HashCommands.HExists(key, field));
コード例 #14
0
 public Task <long> HDelAsync(string key, params string[] fields) => MultiAsync(HashCommands.HDel(key, fields));
コード例 #15
0
 public long HDel(string key, params string[] fields) => Multi(HashCommands.HDel(key, fields));
コード例 #16
0
 public long HLen(string key) => Multi(HashCommands.HLen(key));
コード例 #17
0
 public Task <long> HLenAsync(string key) => MultiAsync(HashCommands.HLen(key));
コード例 #18
0
 public Task <Dictionary <string, string> > HGetAllAsync(string key) => MultiAsync(HashCommands.HGetAll(key));
コード例 #19
0
 public string HMSet(string key, Dictionary <string, string> dict) => Multi(HashCommands.HMSet(key, dict));
コード例 #20
0
 public long HIncrBy(string key, string field, long increment) => Multi(HashCommands.HIncrBy(key, field, increment));
コード例 #21
0
 public bool HSetNx(string key, string field, object value) => Multi(HashCommands.HSetNx(key, field, value));
コード例 #22
0
 public Task <long> HIncrByAsync(string key, string field, long increment) => MultiAsync(HashCommands.HIncrBy(key, field, increment));
コード例 #23
0
        /// <summary>
        /// Sends a command string to the mud.
        /// </summary>
        /// <param name="cmd"></param>
        /// <param name="silent">Whether the commands should be outputted to the game window.</param>
        public async Task Send(string cmd, bool silent, bool addToInputHistory)
        {
            // Add the whole thing to the command history
            if (addToInputHistory)
            {
                AddInputHistory(cmd);
            }

            _aliasRecursionDepth = 0;
            var cmdList = ParseCommand(cmd);

            foreach (string item in cmdList)
            {
                if (Telnet == null)
                {
                    Conveyor.EchoLog("You are not connected to the game.", LogType.Error);
                    return;
                }

                try
                {
                    if (item.SafeLeft(1) != "#")
                    {
                        // Show the command in the window that was sent.
                        if (!silent)
                        {
                            EchoText(item, AnsiColors.Yellow);
                        }

                        // Spam guard
                        if (App.Settings.ProfileSettings.SpamGuard)
                        {
                            // TODO, make this check carriage return and > 1 instead of > 2
                            if (_spamGuardLastCommand == item && item.Length > 2)
                            {
                                // Increment, we don't need to change the last command, it was the same.
                                _spamGuardCounter++;
                            }
                            else
                            {
                                _spamGuardLastCommand = item;
                                _spamGuardCounter     = 0;
                            }

                            if (_spamGuardCounter == 15)
                            {
                                EchoText("where", AnsiColors.Yellow);
                                await Telnet.Send("where");

                                _spamGuardCounter = 0;
                            }
                        }


                        await Telnet.Send(item);
                    }
                    else
                    {
                        var hashCmd = HashCommands.FirstOrDefault(x => x.Name == item.FirstWord());

                        if (hashCmd == null)
                        {
                            Conveyor.EchoLog($"Hash command '{item.FirstWord()}' was not found.\r\n", LogType.Error);
                        }
                        else
                        {
                            string parameters = item.RemoveWord(1);
                            hashCmd.Parameters = parameters;

                            if (hashCmd.IsAsync)
                            {
                                await hashCmd.ExecuteAsync();
                            }
                            else
                            {
                                hashCmd.Execute();
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    EchoText(ex.Message, AnsiColors.Red);
                }
            }
        }
コード例 #24
0
 public double?HIncrByFloat(string key, string field, double increment) => Multi(HashCommands.HIncrByFloat(key, field, increment));