Esempio n. 1
0
        private IClientSessionHandle StartSession(ClientSessionOptions options, bool areSessionsSupported)
        {
            if (!areSessionsSupported)
            {
                throw new NotSupportedException("Sessions are not supported by this version of the server.");
            }

            options = options ?? new ClientSessionOptions();
            var coreSession = _cluster.StartSession(options.ToCore());

            return(new ClientSessionHandle(this, options, coreSession));
        }
Esempio n. 2
0
 // private methods
 private IClientSessionHandle CreateSession(bool usingSession)
 {
     if (usingSession)
     {
         var client            = new Mock <IMongoClient>().Object;
         var options           = new ClientSessionOptions();
         var coreServerSession = new CoreServerSession();
         var coreSession       = new CoreSession(coreServerSession, options.ToCore());
         var coreSessionHandle = new CoreSessionHandle(coreSession);
         return(new ClientSessionHandle(client, options, coreSessionHandle));
     }
     else
     {
         return(null);
     }
 }
Esempio n. 3
0
        private IClientSessionHandle StartSession(ClientSessionOptions options, bool areSessionsSupported)
        {
            options = GetEffectiveClientSessionOptions(options);

            ICoreSessionHandle coreSession;

            if (areSessionsSupported)
            {
                coreSession = _cluster.StartSession(options.ToCore());
            }
            else
            {
                throw new NotSupportedException("Sessions are not supported by this version of the server.");
            }

            return(new ClientSessionHandle(this, options, coreSession));
        }
Esempio n. 4
0
        private IClientSessionHandle StartSession(ClientSessionOptions options, bool areSessionsSupported)
        {
            if (!areSessionsSupported)
            {
                throw new NotSupportedException("Sessions are not supported by this version of the server.");
            }

            if (options != null && options.Snapshot && options.CausalConsistency == true)
            {
                throw new NotSupportedException("Combining both causal consistency and snapshot options is not supported.");
            }

            options = options ?? new ClientSessionOptions();
            var coreSession = _cluster.StartSession(options.ToCore());

            return(new ClientSessionHandle(this, options, coreSession));
        }
Esempio n. 5
0
        private IClientSessionHandle StartImplicitSession(bool areSessionsSupported)
        {
            var options = new ClientSessionOptions();

            ICoreSessionHandle coreSession;

#pragma warning disable 618
            var areMultipleUsersAuthenticated = _settings.Credentials.Count() > 1;
#pragma warning restore
            if (areSessionsSupported && !areMultipleUsersAuthenticated)
            {
                coreSession = _cluster.StartSession(options.ToCore(isImplicit: true));
            }
            else
            {
                coreSession = NoCoreSession.NewHandle();
            }

            return(new ClientSessionHandle(this, options, coreSession));
        }