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)); }
private IClientSessionHandle StartImplicitSession(bool areSessionsSupported) { var options = new ClientSessionOptions(); IServerSession serverSession; #pragma warning disable 618 var areMultipleUsersAuthenticated = _settings.Credentials.Count() > 1; #pragma warning restore if (areSessionsSupported && !areMultipleUsersAuthenticated) { serverSession = AcquireServerSession(); } else { serverSession = NoServerSession.Instance; } var session = new ClientSession(this, options, serverSession, isImplicit: true); return(new ClientSessionHandle(session)); }
/// <inheritdoc/> public sealed override async Task <IClientSessionHandle> StartSessionAsync(ClientSessionOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) { var areSessionsSupported = await AreSessionsSupportedAsync(cancellationToken).ConfigureAwait(false); return(StartSession(options, areSessionsSupported)); }
/// <inheritdoc/> public sealed override IClientSessionHandle StartSession(ClientSessionOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) { var areSessionsSupported = AreSessionsSupported(cancellationToken); return(StartSession(options, areSessionsSupported)); }
// constructors /// <summary> /// Initializes a new instance of the <see cref="ClientSessionHandle" /> class. /// </summary> /// <param name="client">The client.</param> /// <param name="options">The options.</param> /// <param name="coreSession">The wrapped session.</param> public ClientSessionHandle(IMongoClient client, ClientSessionOptions options, ICoreSessionHandle coreSession) : this(client, options, coreSession, SystemClock.Instance) { }
/// <inheritdoc /> public virtual Task <IClientSessionHandle> StartSessionAsync(ClientSessionOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) { throw new NotImplementedException(); }