// methods public bool Execute(IWriteBinding binding, CancellationToken cancellationToken) { using (var channelSource = binding.GetWriteChannelSource(cancellationToken)) using (var channel = channelSource.GetChannel(cancellationToken)) using (var channelBinding = new ChannelReadWriteBinding(channelSource.Server, channel, binding.Session.Fork())) { var operation = new AddUserUsingUserManagementCommandsOperation( _databaseNamespace, _username, _passwordHash, _readOnly, _messageEncoderSettings); return(operation.Execute(channelBinding, cancellationToken)); } }
// methods public async Task <bool> ExecuteAsync(IWriteBinding binding, CancellationToken cancellationToken) { using (var channelSource = await binding.GetWriteChannelSourceAsync(cancellationToken).ConfigureAwait(false)) { IWriteOperation <bool> operation; if (channelSource.ServerDescription.Version >= __serverVersionSupportingUserManagementCommands) { operation = new AddUserUsingUserManagementCommandsOperation(_databaseNamespace, _username, _passwordHash, _readOnly, _messageEncoderSettings); } else { operation = new AddUserUsingSystemUsersCollectionOperation(_databaseNamespace, _username, _passwordHash, _readOnly, _messageEncoderSettings); } return(await operation.ExecuteAsync(channelSource, cancellationToken).ConfigureAwait(false)); } }
// methods public bool Execute(IWriteBinding binding, CancellationToken cancellationToken) { using (var channelSource = binding.GetWriteChannelSource(cancellationToken)) using (var channel = channelSource.GetChannel(cancellationToken)) using (var channelBinding = new ChannelReadWriteBinding(channelSource.Server, channel, binding.Session.Fork())) { IWriteOperation <bool> operation; if (Feature.UserManagementCommands.IsSupported(channel.ConnectionDescription.ServerVersion)) { operation = new AddUserUsingUserManagementCommandsOperation(_databaseNamespace, _username, _passwordHash, _readOnly, _messageEncoderSettings); } else { operation = new AddUserUsingSystemUsersCollectionOperation(_databaseNamespace, _username, _passwordHash, _readOnly, _messageEncoderSettings); } return(operation.Execute(channelBinding, cancellationToken)); } }