示例#1
0
        public IFilesStore Initialize(bool ensureFileSystemExists)
        {
            if (initialized)
            {
                return(this);
            }

            jsonRequestFactory = new HttpJsonRequestFactory(MaxNumberOfCachedRequests, HttpMessageHandler);

            try
            {
                InitializeInternal();

                initialized = true;

                if (ensureFileSystemExists && string.IsNullOrEmpty(DefaultFileSystem) == false)
                {
                    AsyncFilesCommands.ForFileSystem(DefaultFileSystem)
                    .EnsureFileSystemExistsAsync()
                    .Wait();
                }
            }
            catch (Exception)
            {
                Dispose();
                throw;
            }

            return(this);
        }
示例#2
0
        public IFilesStore Initialize(bool ensureFileSystemExists = true, bool failIfCannotCreate = true)
        {
            if (initialized)
            {
                return(this);
            }
            disableReplicationInformerGeneration = true;
            jsonRequestFactory = new HttpJsonRequestFactory(MaxNumberOfCachedRequests, HttpMessageHandlerFactory, authenticationScheme: conventions.AuthenticationScheme);

            try
            {
                SecurityExtensions.InitializeSecurity(Conventions, jsonRequestFactory, Url, Credentials);

                InitializeInternal();

                initialized = true;

                if (ensureFileSystemExists && string.IsNullOrEmpty(DefaultFileSystem) == false)
                {
                    try
                    {
                        AsyncFilesCommands.ForFileSystem(DefaultFileSystem).EnsureFileSystemExistsAsync().GetAwaiter().GetResult();
                    }
                    catch (Exception)
                    {
                        if (failIfCannotCreate)
                        {
                            throw;
                        }
                    }
                }
            }
            catch (Exception)
            {
                Dispose();
                throw;
            }
            finally
            {
                disableReplicationInformerGeneration = false;
            }

            return(this);
        }
示例#3
0
        public IFilesStore Initialize(bool ensureFileSystemExists = true, bool failIfCannotCreate = true)
        {
            if (initialized)
            {
                return(this);
            }

            jsonRequestFactory = new HttpJsonRequestFactory(MaxNumberOfCachedRequests, HttpMessageHandlerFactory);

            try
            {
                SecurityExtensions.InitializeSecurity(Conventions, JsonRequestFactory, Url);

                InitializeInternal();

                initialized = true;

                if (ensureFileSystemExists && string.IsNullOrEmpty(DefaultFileSystem) == false)
                {
                    try
                    {
                        AsyncFilesCommands.ForFileSystem(DefaultFileSystem)
                        .EnsureFileSystemExistsAsync().ConfigureAwait(false)
                        .GetAwaiter().GetResult();
                    }
                    catch (Exception)
                    {
                        if (failIfCannotCreate)
                        {
                            throw;
                        }
                    }
                }
            }
            catch (Exception)
            {
                Dispose();
                throw;
            }

            return(this);
        }
示例#4
0
        protected virtual IFilesChanges CreateFileSystemChanges(string filesystem)
        {
            if (string.IsNullOrEmpty(Url))
            {
                throw new InvalidOperationException("Changes API requires usage of server/client");
            }

            var tenantUrl = Url + "/fs/" + filesystem;

            var commands = fileSystemCommands.GetOrAdd(filesystem, x => (IAsyncFilesCommandsImpl)AsyncFilesCommands.ForFileSystem(x));

            using (NoSynchronizationContext.Scope())
            {
                var client = new FilesChangesClient(tenantUrl,
                                                    ApiKey,
                                                    Credentials,
                                                    jsonRequestFactory,
                                                    Conventions,
                                                    commands.ReplicationInformer,
                                                    ((AsyncFilesServerClient)AsyncFilesCommands).TryResolveConflictByUsingRegisteredListenersAsync,
                                                    () =>
                {
                    fileSystemChanges.Remove(filesystem);
                    fileSystemCommands.Remove(filesystem);
                });

                return(client);
            }
        }