示例#1
0
        public async Task <IActionResult> UploadFastQFileAsync(List <IFormFile> files)
        {
            string tempBasePath = CheckBaseTempPath();

            if (Request.Form.Files.Count > 0)  //get  first
            {
                string fileFullPath = tempBasePath + DateTime.Now.Millisecond + Request.Form.Files[0].FileName;
                using (var stream = new FileStream(fileFullPath, FileMode.Create))
                {
                    await Request.Form.Files[0].CopyToAsync(stream);
                }

                string guid = CommandMap.FastqToFasta(fileFullPath, fileFullPath + ".out.fasta");
                HttpContext.Session.SetString("guid", guid);
                return(Json(new FastqToFasaQueryRes()
                {
                    Code = 0,
                    Guid = guid
                }));
            }

            return(Json(new FastqToFasaQueryRes()
            {
                Code = 500,
            }));
        }
示例#2
0
        public static IServiceCollection AddRedis(this IServiceCollection services, CommandMap commandMap = null, Version version = null)
        {
            services.AddSingleton(provider =>
            {
                var configuration = provider.GetRequiredService <IConfiguration>();
                var redisConfig   = configuration.GetSection(nameof(RedisConfig)).Get <RedisConfig>();

                if (redisConfig == null)
                {
                    throw new Exception($"{nameof(RedisConfig)} must not be null");
                }

                if (string.IsNullOrEmpty(redisConfig.Ip))
                {
                    throw new Exception($"{nameof(RedisConfig)}.{nameof(RedisConfig.Ip)} must not be null or empty");
                }

                redisConfig.CommandMap = commandMap ?? CommandMap.Default;
                redisConfig.Version    = version ?? new Version(5, 0);

                return(redisConfig);
            });

            services.AddSingleton <IRedisClient, RedisClient>();

            return(services);
        }
示例#3
0
            public UpdateObjEditCards(ReflexPanel parent /*, ref Shared shared*/)
            {
                this.parent = parent;
                commandMap  = new CommandMap(@"ReflexPanel");

                updateList = new List <UpdateObject>();
            }
示例#4
0
        public string GetConnectionString()
        {
            var configurationOptions = new ConfigurationOptions
            {
                ConnectTimeout = _options.ConnectionTimeout,
                Password       = _options.Password,
                Ssl            = _options.IsSsl,
                SslHost        = _options.SslHost,
                CommandMap     = CommandMap.Create(_options.CommandMap)
            };

            try
            {
                configurationOptions.Password = configurationOptions.Password;
            }
            catch
            {
                _logger.LogCritical("Redis Password was not encrypted!!!");
            }

            var list = _options.Servers.Distinct();

            foreach (var endpoint in list)
            {
                configurationOptions.EndPoints.Add(endpoint.Host, int.Parse(endpoint.Port));
            }

            return(configurationOptions.ToString());
        }
 public MainWindowViewModel()
 {
     this._signupVisibility  = new ButtonVisibility();
     this._welcomeVisibility = new ButtonVisibility();
     this.LoggedText         = string.Empty;
     this.ChangeApplicationState(E_APPLICATION_STATE.E_APPLICATION_USER_LOGGED_OUT);
     this.Commands = new CommandMap();
     this.Commands.AddCommand("LoginButtonCommand",
                              x =>
     {
         this.ChangeBody(E_BODY_TYPES.E_BODY_LOGIN);
     });
     this.Commands.AddCommand("CreateNewPasteCommand",
                              x =>
     {
         this.ChangeBody(E_BODY_TYPES.E_BODY_MAIN);
     });
     this.Commands.AddCommand("LogoutCommand",
                              x =>
     {
         MessageBox.Show(UserSession.Instance.Username);
         this.ChangeApplicationState(E_APPLICATION_STATE.E_APPLICATION_USER_LOGGED_OUT);
         this.ChangeBody(E_BODY_TYPES.E_BODY_MAIN);
     });
     this._mainBodyView       = new MainBodyView();
     this._mainBodyViewModel  = new MainBodyViewModel(this);
     this._loginBodyView      = new LoginBodyView();
     this._loginBodyViewModel = new LoginBodyViewModel(this);
     this.ChangeBody(E_BODY_TYPES.E_BODY_MAIN);
 }
    /// <summary>
    /// Override for the Do function
    /// </summary>
    /// <param name="prCmd"></param>
    public override void Do(CommandMap prCmd)
    {
        base.Do(prCmd); // consume
        string lcDirection = Command.Tokens[Command.CurrentToken];

        GameManager.DebugLog("Got a Go" + lcDirection);

        Area   lcArea           = GameModel.CurrentPlayer.CurrentArea;  // Shortcut to the current area
        string lcCurrentCnvName = GameManager.Instance.CurrentCnv.name; // Shortcut to the canvas that the player is currently on

        if (lcCurrentCnvName == "CnvGame")                              // Check that the current canvas is the game canvas
        {
            if (GameModel.CurrentPlayer.Move(lcDirection) == true)      // try to move
            {
                prCmd.Result  = GameModel.CurrentPlayer.CurrentArea.AreaText + "\n";
                prCmd.Result += GameModel.CurrentPlayer.CurrentArea.ItemsText;
                prCmd.Result += GameModel.CurrentPlayer.CurrentArea.DestinationText;
            }
            else
            {
                prCmd.Result = "Not a valid direction!";
            }
        }
        else
        {
            prCmd.Result = "Not able to go places when in " + lcCurrentCnvName;
        }
    }
    /// <summary>
    /// Override for the Do function
    /// </summary>
    /// <param name="prCmd"></param>
    public override void Do(CommandMap prCmd)
    {
        base.Do(prCmd); // consume
        GameManager.DebugLog("Got a Pick" + Command.Tokens[CurrentToken]);
        if (Command.Tokens[CurrentToken].ToLower() == "up")
        {
            Command.Consume();
        }

        Area   lcArea           = GameModel.CurrentPlayer.CurrentArea;  // Shortcut to the current area
        string lcCurrentCnvName = GameManager.Instance.CurrentCnv.name; // Shortcut to the canvas that the player is currently on

        if (lcCurrentCnvName == "CnvGame")                              // Check that the current canvas is the game canvas
        {
            foreach (Item prItem in lcArea.LstItems)
            {
                if (Command.Tokens[CurrentToken] == prItem.ItemName)
                {
                    GameModel.CurrentPlayer.PickUpItem(prItem);
                    prCmd.Result = prItem.TextOnPickup;
                    break;
                }
                else
                {
                    prCmd.Result = "Could not pick up that item!";
                }
            }
        }
        else
        {
            prCmd.Result = "Not able to go places when in " + lcCurrentCnvName;
        }
    }
    /// <summary>
    /// Override for the Do function
    /// </summary>
    /// <param name="prCmd"></param>
    public override void Do(CommandMap prCmd)
    {
        base.Do(prCmd); // consume


        GameManager.DebugLog("Got a Use" + Command.Tokens[Command.CurrentToken]);

        string lcCurrentCnvName = GameManager.Instance.CurrentCnv.name; // Shortcut to the canvas that the player is currently on

        if (lcCurrentCnvName == "CnvGame")                              // Check that the current canvas is the game canvas
        {
            foreach (Item prItem in GameModel.CurrentPlayer.LstInventory)
            {
                if (prItem.ItemName == Tokens[CurrentToken])
                {
                    prCmd.Result = GameModel.CurrentPlayer.Use(prItem);
                    GameModel.DB.SetPlayer(GameModel.CurrentPlayer);

                    break;
                }
            }
        }
        else
        {
            prCmd.Result = "Not able to go places when in " + lcCurrentCnvName;
        }
    }
    /// <summary>
    /// Override for the Do function
    /// </summary>
    /// <param name="prCmd"></param>
    public override void Do(CommandMap prCmd)
    {
        base.Do(prCmd); // consume

        string lcResult = "";

        GameManager.DebugLog("Got an Attack" + Command.Tokens[Command.CurrentToken]);

        Area   lcArea           = GameModel.CurrentPlayer.CurrentArea;  // Shortcut to the current area
        string lcCurrentCnvName = GameManager.Instance.CurrentCnv.name; // Shortcut to the canvas that the player is currently on

        if (lcCurrentCnvName == "CnvGame")                              // Check that the current canvas is the game canvas
        {
            if (lcArea.Boss != null)
            {
                if (lcArea.Boss.AreaName == lcArea.AreaName)
                {
                    lcResult = GameModel.CurrentPlayer.Attack(lcArea.Boss);
                    GameModel.DB.SetPlayer(GameModel.CurrentPlayer);
                    GameModel.DB.SetArea(lcArea);
                }
            }
            else
            {
                lcResult = "No boss to attack";
            }
        }
        else
        {
            lcResult = "Not able to go places when in " + lcCurrentCnvName;
        }


        prCmd.Result = lcResult;
    }
    /// <summary>
    /// Override for the Do function
    /// </summary>
    /// <param name="prCmd"></param>
    public override void Do(CommandMap prCmd)
    {
        base.Do(prCmd); // consume

        string lcResult = "";

        GameManager.DebugLog("Got a Show" + Command.Tokens[Command.CurrentToken]);
        switch (Command.Tokens[Command.CurrentToken])
        {
        case "game":
            GameManager.Instance.SwitchToCanvas(GameManager.Instance.CnvGame);

            break;

        case "map":
            GameManager.Instance.SwitchToCanvas(GameManager.Instance.CnvMap);
            break;

        case "inventory":
            GameManager.Instance.SwitchToCanvas(GameManager.Instance.CnvInventory);
            break;

        default:
            lcResult = "Do not understand. Did you mean \"show game\", \"show map\", or \"show inventory\"?";
            break;
        }
        prCmd.Result = lcResult;
    }
示例#11
0
        virtual public IQueryStatusResult CommandBeforeQueryStatus(ICommandQueryStatusParams e)
        {
            var  result    = new QueryStatusResult();
            var  prgcmds   = (OLECMD[])e.PrgCmds;
            uint wtfisthis = prgcmds[0].cmdf;
            int  commandID = Convert.ToInt32(prgcmds[0].cmdID);

            if (CommandMap.ContainsKey(commandID))
            {
                var  mappedCommand = CommandMap[commandID];
                bool isVisible     = mappedCommand.BaseCommand.BeforeQueryStatus(mappedCommand.MenuCommand, new EventArgs());
                wtfisthis |= (uint)OLECMDF.OLECMDF_SUPPORTED | (uint)OLECMDF.OLECMDF_ENABLED;
                if (!isVisible)
                {
                    wtfisthis = (uint)OLECMDF.OLECMDF_DEFHIDEONCTXTMENU | (uint)OLECMDF.OLECMDF_SUPPORTED | (uint)OLECMDF.OLECMDF_INVISIBLE;
                }
                result.IsVersionControlled = isVisible;
            }
            else
            {
            }
            result.PrgCmdsValue = wtfisthis;
            result.ReturnValue  = 0;
            return(result);
        }
示例#12
0
        static void Main(string[] args)
        {
            // Connection setup
            var configurationOptions = new ConfigurationOptions
            {
                EndPoints            = { "pub-redis-19354.eu-central-1-1.1.ec2.redislabs.com:19354" },
                KeepAlive            = 10,
                AbortOnConnectFail   = false,
                ConfigurationChannel = "",
                TieBreaker           = "",
                ConfigCheckSeconds   = 0,
                CommandMap           = CommandMap.Create(new HashSet <string>
                { // EXCLUDE a few commands
                    "SUBSCRIBE", "UNSUBSCRIBE", "CLUSTER"
                }, available: false),

                Password = "******"
            };

            ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(configurationOptions);

            // Standard connection
            IDatabase db = redis.GetDatabase();

            RedisValue reply = db.HashGet("myHash", "myElem");

            Console.WriteLine(reply);
        }
示例#13
0
 /// <summary>
 ///     Заполняет карту комманд (для вызова пользователя)
 ///     Командный лист не содержит служебных комманд!
 /// </summary>
 private void FillCommandMap()
 {
     foreach (var command in Commands)
     {
         CommandMap.Add(command.Name, command);
     }
 }
示例#14
0
        private string GetConnectionString()
        {
            var redisConfig = new ConfigurationOptions
            {
                AbortOnConnectFail = false,
                Ssl                  = Convert.ToBoolean(this._redisConfig.SSL),
                ConnectRetry         = 3,
                ConnectTimeout       = 1000 * 30,
                AsyncTimeout         = 1000 * 3,
                SyncTimeout          = 1000 * 3,
                ReconnectRetryPolicy = new ExponentialRetry(5000, 30000),
                DefaultDatabase      = 0,
                AllowAdmin           = true,
                CommandMap           = CommandMap.Create(new HashSet <string> {
                    "INFO", "ECHO"
                }, available: false),
                EndPoints =
                {
                    { this._redisConfig.HostName, Convert.ToInt32(this._redisConfig.Port) }
                },
                Password = this._redisConfig.Key
            };

            return(redisConfig.ToString());
        }
示例#15
0
        public static string GetRedisConnectionString()
        {
            var settings = ParseVCAP();

            if (null != settings.RedisPassword)
            {
                ConfigurationOptions config = new ConfigurationOptions
                {
                    EndPoints =
                    {
                        { settings.RedisHost }//, int.Parse(settings.RedisPort)}
                    },
                    CommandMap = CommandMap.Create(new HashSet <string>
                    { // EXCLUDE a few commands
                      /*"INFO", "CONFIG", "CLUSTER",*/
                        "PING", "ECHO",
                    }, available: false),
                    KeepAlive      = 180,
                    DefaultVersion = new Version(2, 8, 8),
                    Password       = settings.RedisPassword
                };
                return(config.ToString());
            }
            return(null);
        }
示例#16
0
文件: Commands.cs 项目: fog-bank/mojp
        public Command(MainViewModel viewModel, string name)
        {
            ViewModel = viewModel;
            Name      = name;

            CommandMap.Add(name, this);
        }
示例#17
0
    //parse the input text
    public static string Parse(string prCommand)
    {
        prCommand = prCommand.ToLower();
        string[]   commandParts   = prCommand.Split(' ');
        CommandMap validateChoice = new CommandMap();

        if (commandParts.Length >= 2)
        {
            //prompt user to enter correct command
            return(CombatChoice.instance.AllCombatText += "\n" + "please enter single word commands");
        }

        else
        {
            if (validateChoice.validAction(prCommand))
            {
                return(CombatChoice.instance.AllCombatText);
            }
            //prompt user to enter correct command
            else
            {
                return(CombatChoice.instance.AllCombatText + "please enter a combat choice");
            }
        }
    }
示例#18
0
        public void RedisLabsSSL()
        {
            Skip.IfNoConfig(nameof(TestConfig.Config.RedisLabsSslServer), TestConfig.Current.RedisLabsSslServer);
            Skip.IfNoConfig(nameof(TestConfig.Config.RedisLabsPfxPath), TestConfig.Current.RedisLabsPfxPath);

            var cert = new X509Certificate2(TestConfig.Current.RedisLabsPfxPath, "");

            Assert.NotNull(cert);
            Writer.WriteLine("Thumbprint: " + cert.Thumbprint);

            int timeout = 5000;

            if (Debugger.IsAttached)
            {
                timeout *= 100;
            }
            var options = new ConfigurationOptions
            {
                EndPoints      = { { TestConfig.Current.RedisLabsSslServer, TestConfig.Current.RedisLabsSslPort } },
                ConnectTimeout = timeout,
                AllowAdmin     = true,
                CommandMap     = CommandMap.Create(new HashSet <string> {
                    "subscribe", "unsubscribe", "cluster"
                }, false)
            };

            options.TrustIssuer("redislabs_ca.pem");

            if (!Directory.Exists(Me()))
            {
                Directory.CreateDirectory(Me());
            }
#if LOGOUTPUT
            ConnectionMultiplexer.EchoPath = Me();
#endif
            options.Ssl = true;
            options.CertificateSelection += delegate
            {
                return(cert);
            };
            RedisKey key = Me();
            using (var conn = ConnectionMultiplexer.Connect(options))
            {
                var db = conn.GetDatabase();
                db.KeyDelete(key, CommandFlags.FireAndForget);
                string s = db.StringGet(key);
                Assert.Null(s);
                db.StringSet(key, "abc", flags: CommandFlags.FireAndForget);
                s = db.StringGet(key);
                Assert.Equal("abc", s);

                var latency = db.Ping();
                Log("RedisLabs latency: {0:###,##0.##}ms", latency.TotalMilliseconds);

                using (var file = File.Create("RedisLabs.zip"))
                {
                    conn.ExportConfiguration(file);
                }
            }
        }
示例#19
0
        private ConfigurationOptions GetConfigurationOptions(bool isForceAllowAdmin = false)
        {
            var endPointFirst = BedrockConfiguration.Cache.Redis.EndPoints.First();

            var returnValue = new ConfigurationOptions
            {
                AbortOnConnectFail   = BedrockConfiguration.Cache.Redis.AbortOnConnectFail,
                AllowAdmin           = isForceAllowAdmin ? true : BedrockConfiguration.Cache.Redis.AllowAdmin,
                ChannelPrefix        = BedrockConfiguration.Cache.Redis.ChannelPrefix,
                ClientName           = BedrockConfiguration.Cache.Redis.ClientName,
                CommandMap           = CommandMap.Create(new HashSet <string>(BedrockConfiguration.Cache.Redis.Commands), available: BedrockConfiguration.Cache.Redis.IsCommandsAvailable),
                ConfigCheckSeconds   = BedrockConfiguration.Cache.Redis.ConfigCheckSeconds,
                ConfigurationChannel = BedrockConfiguration.Cache.Redis.ConfigurationChannel,
                ConnectRetry         = BedrockConfiguration.Cache.Redis.ConnectRetry,
                ConnectTimeout       = BedrockConfiguration.Cache.Redis.ConnectTimeout,
                DefaultDatabase      = BedrockConfiguration.Cache.Redis.DefaultDatabase,
                DefaultVersion       = new Version(BedrockConfiguration.Cache.Redis.DefaultVersion),
                KeepAlive            = BedrockConfiguration.Cache.Redis.KeepAlive,
                Password             = BedrockConfiguration.Cache.Redis.Password,
                Proxy           = (Proxy)BedrockConfiguration.Cache.Redis.Proxy,
                ResolveDns      = BedrockConfiguration.Cache.Redis.ResolveDns,
                ResponseTimeout = BedrockConfiguration.Cache.Redis.ResponseTimeout,
                ServiceName     = BedrockConfiguration.Cache.Redis.ServiceName,
                Ssl             = BedrockConfiguration.Cache.Redis.Ssl,
                SslHost         = BedrockConfiguration.Cache.Redis.SslHost,
                SyncTimeout     = BedrockConfiguration.Cache.Redis.SyncTimeout,
                TieBreaker      = BedrockConfiguration.Cache.Redis.TieBreaker
            };

            SetEndPoints(returnValue);

            return(returnValue);
        }
示例#20
0
        public static void RemovePlugin <T>()
        {
            foreach (var item in CommandMap)
            {
                if (typeof(T) != item.Value.GetType())
                {
                    continue;
                }
                CommandMap.Remove(item.Key, out _);
            }

            foreach (var item in ServiceList)
            {
                if (typeof(T) != item.GetType())
                {
                    continue;
                }
                ServiceList.Remove(item);
            }

            foreach (var item in ApplicationList)
            {
                if (typeof(T) != item.GetType())
                {
                    continue;
                }
                ApplicationList.Remove(item);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="RedisAddressList"></param>
        /// <param name="Password">默认无密码</param>
        /// <param name="DbIndex"></param>
        public RedisExChangeHelper(IList <string> RedisAddressList = null, string Password = "", int DbIndex = -1)
        {
            ConfigurationOptions opt = new ConfigurationOptions
            {
                CommandMap = CommandMap.Create(new HashSet <string>
                {
                    "INFO",
                    "CONFIG",
                    "CLUSTER",
                    "PING",
                    "ECHO",
                    "CLIENT"
                }, available: false),
                KeepAlive = 120
            };

            if (RedisAddressList == null || RedisAddressList.Count == 0)
            {
                RedisAddressList.Add("127.0.0.1:6379");
            }

            if (!string.IsNullOrEmpty(Password))
            {
                opt.Password = Password;
            }


            foreach (var item in RedisAddressList)
            {
                opt.EndPoints.Add(item);
            }

            RedisMgr = ConnectionMultiplexer.Connect(opt);
            Redis    = RedisMgr.GetDatabase(DbIndex);
        }
示例#22
0
        public ConfigurationOptions GetOptions()
        {
            var config = new ConfigurationOptions
            {
                CommandMap           = CommandMap.Create(ExcludedCommands, false),
                KeepAlive            = KeepAlive,      // 60 sec to ensure connection is alive
                ConnectTimeout       = ConnectTimeout, // 5 sec
                SyncTimeout          = SyncTimeout,    // 5 sec
                AllowAdmin           = AllowAdmin,
                AbortOnConnectFail   = false,
                ReconnectRetryPolicy = new ExponentialRetry(500, 10000)
            };

            if (!string.IsNullOrEmpty(Password))
            {
                config.Password = Password;
            }

            foreach (var endpoint in Endpoints)
            {
                config.EndPoints.Add(endpoint.Host, endpoint.Port);
            }

            return(config);
        }
        public StupidRedisCaching(IConfiguration config)
        {
            var redis = config.GetSection("Caching:Redis");
            ConfigurationOptions confRedis = new ConfigurationOptions
            {
                EndPoints =
                {
                    { redis["Host"], 6379 }
                },
                CommandMap = CommandMap.Create(new HashSet <string>()
                { // EXCLUDE a few commands
                    "INFO", "CONFIG", "CLUSTER",
                    "PING", "ECHO", "CLIENT"
                }, available: false),
                KeepAlive            = 180,
                ConnectTimeout       = 2000,
                ReconnectRetryPolicy = new ExponentialRetry(7500),
                ConnectRetry         = 2,
                AbortOnConnectFail   = false
            };

            if (!string.IsNullOrEmpty(redis["Password"]))
            {
                confRedis.Password = redis["Password"];
            }
            //string connString = $"{redis["Host"]},password={redis["Password"]}";
            _multiplexer = ConnectionMultiplexer.Connect(confRedis);
        }
        /// <summary>
        /// 获取可用连接,最小负载
        /// </summary>
        /// <returns></returns>
        private ConnectionMultiplexer GetLeastLoadedConn()
        {
            if (this.connectionPool.Count < this.poolSize)
            {
                lock (this.objLock)
                {
                    if (this.connectionPool.Count < this.poolSize)
                    {
                        var config = ConfigurationOptions.Parse(this.connectString, true);
                        config.AbortOnConnectFail = false;
                        config.KeepAlive          = 60;
                        config.SyncTimeout        = Math.Max(config.SyncTimeout, 10000);   //默认1秒,最小设置为10秒
                        config.SocketManager      = new SocketManager();                   //每个socketmanager维护了线程池,多建立几个提高并发
                        config.CommandMap         = CommandMap.Create(new HashSet <string> {
                            "SUBSCRIBE"
                        }, false);                                                                                                //禁用订阅发布,否则会多建立一条无用连接
                        var conn = ConnectionMultiplexer.Connect(config);
                        this.connectionPool.Add(conn);
                        return(conn);
                    }
                }
            }

            //最小负载
            var min = this.connectionPool.OrderBy(m => m.GetCounters().TotalOutstanding).First();

            return(min);
        }
示例#25
0
        public ProgressScreen()
        {
            instance = this;

            operations = new List <ProgressOperation>();
            commandMap = new CommandMap(@"App.ProgressScreen");
        }
示例#26
0
            public UpdateObj(NotPieSelector parent)
                : base()
            {
                this.parent = parent;

                commandMap      = new CommandMap(@"NotPieSelector");
                commandMap.name = @"NotPieSelector " + "NOT!!!";
            }
示例#27
0
        private CommandMap CreateMap(CommandBase command)
        {
            var mapCommand = new CommandMap(command);

            mapCommand.Methods.AddRange(this.ActionMapper.Map(command, command.OnlyMethodsWithAttribute, command.UsePrefixInAllMethods, command.PrefixMethods));
            mapCommand.Properties.AddRange(this.ArgumentMapper.Map(command, command.OnlyPropertiesWithAttribute));
            return(mapCommand);
        }
示例#28
0
 /// <summary>
 /// Remove a previously registered <c>ICommand</c> to <c>INotification</c> mapping.
 /// </summary>
 /// <param name="notificationName">the name of the <c>INotification</c> to remove the <c>ICommand</c> mapping for</param>
 public virtual void RemoveCommand(string notificationName)
 {
     if (!CommandMap.ContainsKey(notificationName))
     {
         return;
     }
     MyView.RemoveObserver(notificationName, this);
 }
示例#29
0
            public UpdateObj(TitleScreenMode parent, ref Shared shared)
            {
                this.parent = parent;
                this.shared = shared;

                this.commandMap = new CommandMap(@"TitleScreen");

                updateList = new List <UpdateObject>();
            }   // end of UpdateObj c'tor
示例#30
0
        public NormalMode(TextEditorData editor) : base(editor)
        {
            // normal mode commands
            CommandMap.Add("0", new FirstColumnCommand(editor));
            CommandMap.Add("a", new AppendCommand(editor));
            CommandMap.Add("A", new AppendEndCommand(editor));
            CommandMap.Add("b", new WordBackCommand(editor));
            CommandMap.Add("cc", new ChangeLineCommand(editor));
            CommandMap.Add("ci'", new ChangeInsideSingleQuotesCommand(editor));
            CommandMap.Add("ci\"", new ChangeInsideDoubleQuotesCommand(editor));
            CommandMap.Add("ci(", new ChangeInsideParenthesesCommand(editor));
            CommandMap.Add("ci{", new ChangeInsideBracesCommand(editor));
            CommandMap.Add("ci[", new ChangeInsideBracketsCommand(editor));
            CommandMap.Add("cw", new ChangeWordCommand(editor));
            CommandMap.Add("c$", new ChangeToEndCommand(editor));
            CommandMap.Add("C", new ChangeToEndCommand(editor));
            CommandMap.Add("dd", new DeleteLineCommand(editor));
            CommandMap.Add("dw", new DeleteWordCommand(editor));
            CommandMap.Add("d$", new DeleteLineEndCommand(editor));
            CommandMap.Add("D", new DeleteLineEndCommand(editor));
            CommandMap.Add("f", new FindCommand(editor));
            CommandMap.Add("F", new FindPreviousCommand(editor));
            CommandMap.Add("gg", new GoToLineCommand(editor));
            CommandMap.Add("gd", new GoToDeclarationCommand(editor));
            CommandMap.Add("gt", new GoToNextDocumentCommand(editor));
            CommandMap.Add("gT", new GoToPreviousDocumentCommand(editor));
            CommandMap.Add("G", new GoToLineCommand(editor));
            CommandMap.Add("i", new InsertCommand(editor));
            CommandMap.Add("I", new InsertLineStartCommand(editor));
            CommandMap.Add("J", new JoinCommand(editor));
            CommandMap.Add("n", new SearchNextCommand(editor));
            CommandMap.Add("N", new SearchPreviousCommand(editor));
            CommandMap.Add("o", new OpenBelowCommand(editor));
            CommandMap.Add("O", new OpenAboveCommand(editor));
            CommandMap.Add("p", new PasteAppendCommand(editor));
            CommandMap.Add("P", new PasteInsertCommand(editor));
            CommandMap.Add("r", new ReplaceCommand(editor));
            CommandMap.Add("u", new UndoCommand(editor));
            CommandMap.Add("v", new VisualCommand(editor));
            CommandMap.Add("V", new VisualLineCommand(editor));
            CommandMap.Add("w", new WordCommand(editor));
            CommandMap.Add("x", new DeleteCharacterCommand(editor));
            CommandMap.Add("yy", new YankLineCommand(editor));
            CommandMap.Add("Y", new YankLineCommand(editor));
            CommandMap.Add("zz", new RecenterCommand(editor));
            CommandMap.Add("/", new SearchCommand(editor));
            CommandMap.Add(">", new IndentCommand(editor));
            CommandMap.Add(">>", new IndentOnceCommand(editor));
            CommandMap.Add("<", new RemoveIndentCommand(editor));
            CommandMap.Add("<<", new RemoveIndentOnceCommand(editor));
            CommandMap.Add("%", new MatchingBraceCommand(editor));
            CommandMap.Add("e", new WordEndCommand(editor));
            CommandMap.Add("R", new ReplaceModeCommand(editor));

            // remaps
            //KeyMap.Add("Delete", DeleteCharacter);
        }
        protected string DispatchCommand(CommandMap.Commands command, string parameters)
        {
            switch (command)
            {
                case CommandMap.Commands.None:
                    break;
                case CommandMap.Commands.ListKeys:
                    return CommunicationBridge.ListKeys();
                case CommandMap.Commands.Sendkeys:
                    return CommunicationBridge.SendKeys(GetParams(parameters, ' ', 1)[0]);
                case CommandMap.Commands.ListMacros:
                    return CommunicationBridge.ListMacros();
                case CommandMap.Commands.SendMacro:
                    return CommunicationBridge.SendMacro(GetParams(parameters, ' ', 1)[0]);
                case CommandMap.Commands.Loadfile:
                    break;
                case CommandMap.Commands.RemapKey:
                    return CommunicationBridge.ResponseError + " This command if not implemented yet";
                case CommandMap.Commands.UnloadApplication:
                    var resp = CommunicationBridge.UnloadApplication();
                    if (resp == CommunicationBridge.ResponseOk)
                    {
                        _socketWriter.WriteLine(resp);
                        _socketWriter.Flush();
                        throw new EndOfStreamException();
                    }
                    return resp;

                case CommandMap.Commands.SendToTray:
                    return CommunicationBridge.SendMainWindowToTray();

                case CommandMap.Commands.RestoreWindow:
                    return CommunicationBridge.RestoreMainWindowsFromTray();

                case CommandMap.Commands.StartSocketServer:
                    return CommunicationBridge.StartSocketServer();

                case CommandMap.Commands.StopSocketServer:
                    return CommunicationBridge.StopSocketServer();

                case CommandMap.Commands.Quit:
                    _socketWriter.WriteLine(CommunicationBridge.ResponseOk);
                    _socketWriter.Flush();
                    throw new EndOfStreamException();

                case CommandMap.Commands.Help:
                    ShowHelp();
                    return CommunicationBridge.ResponseOk;

            }

            return (CommunicationBridge.ResponseError + " Invalid Command.");
        }
示例#32
0
        /// <summary>
        /// 初始化网络监听
        /// </summary>
        /// <param name="path"></param>
        private void InitNetFacade(string path)
        {
            string policy = null;
            try
            {
                using (FileStream fs = File.OpenRead(Path.Combine(path, "crossdomain.txt")))
                using (StreamReader sr = new StreamReader(fs, Encoding.UTF8, false))
                {
                    policy = sr.ReadToEnd();
                }
            }
            catch { }

            GMManager.Instance.Load(Path.Combine(path, "GMList.txt"));
            FrontManager.Instance.Load(Path.Combine(path, "FrontIP.txt"));

            AmfStringZip zip = new CommandMap();
            zip.Load(Path.Combine(path, "Command.txt"));

            string ip = "0.0.0.0";
            string ports = "8005";
            int maxClient = 1000;
            int maxWaitSend = 64;

            const int receiveSize = 8 * 1024;
            const int sendSize = 64 * 1024;

            AmfCodec.Init(maxClient, zip);
            IHandshake hander = new Handshaker(policy);

            CommandProcessor gameProcessor = new CommandProcessor(receiveSize, zip);
            SessionFactory gameFactory = new SessionFactory(receiveSize, sendSize, maxWaitSend, gameProcessor);
            server = new GMService(gameFactory, gameFactory, hander);
            server.Start(ip, ports.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries));
        }