示例#1
0
        internal static MongoServer GetMongoServer()
        {
            var serverAddress = (ServerPort != 0)
                                ? new MongoServerAddress(ServerHost, ServerPort)
                                : new MongoServerAddress(ServerHost);
            var connectionStringBuilder = new MongoConnectionStringBuilder
            {
                Server           = serverAddress,
                ConnectTimeout   = ConnectTimeout,
                SocketTimeout    = SocketTimeout,
                WaitQueueTimeout = WaitQueueTimeout,
                SafeMode         = (SafeMode)
                                        ? MongoDB.Driver.SafeMode.True
                                        : MongoDB.Driver.SafeMode.False
            };

            return(MongoServer
                   .Create(connectionStringBuilder.ToServerSettings()));
        }