コード例 #1
0
        private MongoTestServer(int port)
        {
            _port = port;
            List <KeyValuePair <int, MongoTestInstance> > instance =
                (from i in InstancesByPort where i.Key == port select i).ToList();

            if (instance.Any())
            {
                instance.First().Value.Clients++;
                return;
            }

            Directory.CreateDirectory(_mongodPath + port);

            var startInfo = new ProcessStartInfo(string.Format("{0}mongod.exe", _mongodPath))
            {
                WindowStyle = ProcessWindowStyle.Normal,
                Arguments   = String.Format("--port {0} --dbpath {1}", port, _mongodPath + port)
            };

            Process process     = Process.Start(startInfo);
            var     newInstance = new MongoTestInstance {
                Process = process, Clients = 1
            };

            InstancesByPort.Add(port, newInstance);
            Thread.Sleep(3000);
        }
コード例 #2
0
        private MongoTestServer(int port)
        {
            _port = port;
            List<KeyValuePair<int, MongoTestInstance>> instance =
                (from i in InstancesByPort where i.Key == port select i).ToList();
            if (instance.Any())
            {
                instance.First().Value.Clients++;
                return;
            }

            Directory.CreateDirectory(_mongodPath + port);

            var startInfo = new ProcessStartInfo(string.Format("{0}mongod.exe", _mongodPath))
                {
                    WindowStyle = ProcessWindowStyle.Normal,
                    Arguments = String.Format("--port {0} --dbpath {1}", port, _mongodPath + port)
                };

            Process process = Process.Start(startInfo);
            var newInstance = new MongoTestInstance {Process = process, Clients = 1};
            InstancesByPort.Add(port, newInstance);
            Thread.Sleep(3000);
        }