Example #1
0
        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;
            }
        }
Example #2
0
        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);
        }
Example #3
0
        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;
        }
Example #4
0
        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;
            }
        }