Ejemplo n.º 1
0
        /// <summary>
        /// Lets the server know that this thread is about to begin a series of related operations that must all occur
        /// on the same connection. The return value of this method implements IDisposable and can be placed in a
        /// using statement (in which case RequestDone will be called automatically when leaving the using statement).
        /// </summary>
        /// <param name="serverInstance">The server instance this request should be tied to.</param>
        /// <returns>A helper object that implements IDisposable and calls <see cref="RequestDone"/> from the Dispose method.</returns>
        internal virtual IDisposable RequestStart(MongoServerInstance serverInstance)
        {
            var endPoint           = serverInstance.EndPoint;
            var serverSelector     = new EndPointServerSelector(endPoint);
            var coreReadPreference = serverInstance.GetServerDescription().Type.IsWritable() ? ReadPreference.Primary : ReadPreference.Secondary;

            return(RequestStart(serverSelector, coreReadPreference));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Lets the server know that this thread is about to begin a series of related operations that must all occur
        /// on the same connection. The return value of this method implements IDisposable and can be placed in a
        /// using statement (in which case RequestDone will be called automatically when leaving the using statement).
        /// </summary>
        /// <param name="initialDatabase">One of the databases involved in the related operations.</param>
        /// <param name="serverInstance">The server instance this request should be tied to.</param>
        /// <returns>A helper object that implements IDisposable and calls <see cref="RequestDone"/> from the Dispose method.</returns>
        public virtual IDisposable RequestStart(MongoDatabase initialDatabase, MongoServerInstance serverInstance)
        {
            var address            = serverInstance.Address;
            var endPoint           = new DnsEndPoint(address.Host, address.Port);
            var serverSelector     = new EndPointServerSelector(endPoint);
            var coreReadPreference = serverInstance.GetServerDescription().Type.IsWritable() ? ReadPreference.Primary : ReadPreference.Secondary;

            return(RequestStart(serverSelector, coreReadPreference));
        }