public IAsyncFilesSession OpenAsyncSession(OpenFilesSessionOptions sessionOptions) { AssertInitialized(); EnsureNotClosed(); if (string.IsNullOrWhiteSpace(sessionOptions.FileSystem)) { throw new ArgumentException("Filesystem cannot be null, empty or whitespace.", "FileSystem"); } var sessionId = Guid.NewGuid(); currentSessionId = sessionId; try { var client = SetupCommandsAsync(this.AsyncFilesCommands, sessionOptions); var session = new AsyncFilesSession(this, client, this.Listeners, sessionId); AfterSessionCreated(session); return(session); } finally { currentSessionId = null; } }
private static IAsyncFilesCommands SetupCommandsAsync(IAsyncFilesCommands filesCommands, OpenFilesSessionOptions options) { if (string.IsNullOrWhiteSpace(options.FileSystem)) { throw new ArgumentException("Filesystem cannot be null, empty or whitespace.", "FileSystem"); } filesCommands = filesCommands.ForFileSystem(options.FileSystem); if (options.ApiKey != null || options.Credentials != null) { filesCommands = filesCommands.With(new OperationCredentials(options.ApiKey, options.Credentials)); } return(filesCommands); }
private static IAsyncFilesCommands SetupCommandsAsync(IAsyncFilesCommands filesCommands, OpenFilesSessionOptions options) { if (string.IsNullOrWhiteSpace(options.FileSystem)) throw new ArgumentException("Filesystem cannot be null, empty or whitespace.", "FileSystem"); filesCommands = filesCommands.ForFileSystem(options.FileSystem); if (options.ApiKey != null || options.Credentials != null) filesCommands = filesCommands.With(new OperationCredentials(options.ApiKey, options.Credentials)); return filesCommands; }
public IAsyncFilesSession OpenAsyncSession(OpenFilesSessionOptions sessionOptions) { AssertInitialized(); EnsureNotClosed(); if (string.IsNullOrWhiteSpace(sessionOptions.FileSystem)) throw new ArgumentException("Filesystem cannot be null, empty or whitespace.", "FileSystem"); var sessionId = Guid.NewGuid(); currentSessionId = sessionId; try { var client = SetupCommandsAsync(this.AsyncFilesCommands, sessionOptions); var session = new AsyncFilesSession(this, client, this.Listeners, sessionId); AfterSessionCreated(session); return session; } finally { currentSessionId = null; } }