private void ConfigureServices(ServerTestsBase container, RecursiveProcessingMode processingMode, IServiceCollection services)
        {
            IFileSystemFactory    fileSystemFactory    = null;
            IPropertyStoreFactory propertyStoreFactory = null;

            services
            .AddOptions()
            .AddLogging()
            .Configure <CopyHandlerOptions>(
                opt =>
            {
                opt.Mode = processingMode;
            })
            .Configure <MoveHandlerOptions>(
                opt =>
            {
                opt.Mode = processingMode;
            })
            .AddScoped <IWebDavContext>(sp => new TestHost(sp, container.Server.BaseAddress, sp.GetRequiredService <IHttpContextAccessor>()))
            .AddScoped <IHttpMessageHandlerFactory>(sp => new TestHttpMessageHandlerFactory(container.Server))
            .AddScoped(sp => fileSystemFactory ?? (fileSystemFactory = ActivatorUtilities.CreateInstance <InMemoryFileSystemFactory>(sp)))
            .AddScoped(sp => propertyStoreFactory ?? (propertyStoreFactory = ActivatorUtilities.CreateInstance <InMemoryPropertyStoreFactory>(sp)))
            .AddSingleton <ILockManager, InMemoryLockManager>()
            .AddMvcCore()
            .AddApplicationPart(typeof(TestWebDavController).GetTypeInfo().Assembly)
            .AddWebDav();
        }
            public FileSystemServices()
            {
                IPropertyStoreFactory propertyStoreFactory = null;

                var serviceCollection = new ServiceCollection()
                                        .AddOptions()
                                        .AddLogging()
                                        .Configure <InMemoryLockManagerOptions>(
                    opt =>
                {
                    opt.Rounding = new DefaultLockTimeRounding(DefaultLockTimeRoundingMode.OneHundredMilliseconds);
                })
                                        .AddScoped <ILockManager, InMemoryLockManager>()
                                        .AddScoped <IWebDavContext>(sp => new TestHost(sp, new Uri("http://localhost/")))
                                        .AddScoped <InMemoryFileSystemFactory>()
                                        .AddScoped <IFileSystemFactory, MyVirtualRootFileSystemFactory>()
                                        .AddScoped(sp => propertyStoreFactory ?? (propertyStoreFactory = ActivatorUtilities.CreateInstance <InMemoryPropertyStoreFactory>(sp)))
                                        .AddWebDav();

                _rootServiceProvider = serviceCollection.BuildServiceProvider(true);
                _scope = _rootServiceProvider.CreateScope();

                var loggerFactory = _rootServiceProvider.GetRequiredService <ILoggerFactory>();

                loggerFactory.AddDebug(LogLevel.Trace);
            }
Beispiel #3
0
 public MyVirtualRootFileSystemFactory(
     [NotNull] IServiceProvider serviceProvider,
     [NotNull] IPathTraversalEngine pathTraversalEngine,
     [NotNull] ISystemClock systemClock,
     ILockManager lockManager = null,
     IPropertyStoreFactory propertyStoreFactory = null)
     : base(pathTraversalEngine, systemClock, lockManager, propertyStoreFactory)
 {
     _serviceProvider = serviceProvider;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DotNetFileSystemFactory"/> class.
 /// </summary>
 /// <param name="options">The options for this file system</param>
 /// <param name="pathTraversalEngine">The engine to traverse paths</param>
 /// <param name="propertyStoreFactory">The store for dead properties</param>
 /// <param name="lockManager">The global lock manager</param>
 public DotNetFileSystemFactory(
     IOptions <DotNetFileSystemOptions> options,
     IPathTraversalEngine pathTraversalEngine,
     IPropertyStoreFactory propertyStoreFactory = null,
     ILockManager lockManager = null)
 {
     _pathTraversalEngine  = pathTraversalEngine;
     _propertyStoreFactory = propertyStoreFactory;
     _lockManager          = lockManager;
     _options = options.Value;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="InMemoryFileSystemFactory"/> class.
 /// </summary>
 /// <param name="pathTraversalEngine">The engine to traverse paths</param>
 /// <param name="systemClock">Interface for the access to the systems clock</param>
 /// <param name="lockManager">The global lock manager</param>
 /// <param name="propertyStoreFactory">The store for dead properties</param>
 public InMemoryFileSystemFactory(
     IPathTraversalEngine pathTraversalEngine,
     ISystemClock systemClock,
     ILockManager lockManager = null,
     IPropertyStoreFactory propertyStoreFactory = null)
 {
     _pathTraversalEngine  = pathTraversalEngine;
     _systemClock          = systemClock;
     _lockManager          = lockManager;
     _propertyStoreFactory = propertyStoreFactory;
 }
Beispiel #6
0
 public ChainedFileSystemFactory(IOptions <ChainedFileSystemOptions> options,
                                 IPathTraversalEngine pathTraversalEngine,
                                 IServiceProvider serviceProvider,
                                 IPropertyStoreFactory propertyStoreFactory = null,
                                 ILockManager lockManager = null)
 {
     Options              = options.Value;
     ServiceProvider      = serviceProvider;
     LockManager          = lockManager;
     PropertyStoreFactory = propertyStoreFactory;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SQLiteFileSystemFactory"/> class.
 /// </summary>
 /// <param name="options">The options for this file system</param>
 /// <param name="pathTraversalEngine">The engine to traverse paths</param>
 /// <param name="propertyStoreFactory">The store for dead properties</param>
 /// <param name="lockManager">The global lock manager</param>
 public SQLiteFileSystemFactory(
     [NotNull] IOptions <SQLiteFileSystemOptions> options,
     [NotNull] IPathTraversalEngine pathTraversalEngine,
     [CanBeNull] IPropertyStoreFactory propertyStoreFactory = null,
     [CanBeNull] ILockManager lockManager = null)
 {
     _pathTraversalEngine  = pathTraversalEngine;
     _propertyStoreFactory = propertyStoreFactory;
     _lockManager          = lockManager;
     _options = options.Value;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="InMemoryFileSystem"/> class.
        /// </summary>
        /// <param name="mountPoint">The mount point where this file system should be included</param>
        /// <param name="pathTraversalEngine">The engine to traverse paths</param>
        /// <param name="systemClock">Interface for the access to the systems clock</param>
        /// <param name="lockManager">The global lock manager</param>
        /// <param name="propertyStoreFactory">The store for dead properties</param>
        public InMemoryFileSystem(
            ICollection mountPoint,
            IPathTraversalEngine pathTraversalEngine,
            ISystemClock systemClock,
            ILockManager lockManager = null,
            IPropertyStoreFactory propertyStoreFactory = null)
        {
            SystemClock          = systemClock;
            LockManager          = lockManager;
            _pathTraversalEngine = pathTraversalEngine;
            var rootPath = mountPoint?.Path ?? new Uri(string.Empty, UriKind.Relative);

            RootCollection = new InMemoryDirectory(this, mountPoint, rootPath, mountPoint?.Name ?? rootPath.GetName(), true);
            Root           = new AsyncLazy <ICollection>(() => Task.FromResult <ICollection>(RootCollection));
            PropertyStore  = propertyStoreFactory?.Create(this);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DotNetFileSystem"/> class.
        /// </summary>
        /// <param name="options">The options for this file system</param>
        /// <param name="mountPoint">The mount point where this file system should be included</param>
        /// <param name="rootFolder">The root folder</param>
        /// <param name="pathTraversalEngine">The engine to traverse paths</param>
        /// <param name="lockManager">The global lock manager</param>
        /// <param name="propertyStoreFactory">The store for dead properties</param>
        public DotNetFileSystem(
            [NotNull] DotNetFileSystemOptions options,
            [CanBeNull] ICollection mountPoint,
            [NotNull] string rootFolder,
            [NotNull] IPathTraversalEngine pathTraversalEngine,
            ILockManager lockManager = null,
            IPropertyStoreFactory propertyStoreFactory = null)
        {
            LockManager          = lockManager;
            RootDirectoryPath    = rootFolder;
            _pathTraversalEngine = pathTraversalEngine;
            Options       = options;
            PropertyStore = propertyStoreFactory?.Create(this);
            var rootPath = mountPoint?.Path ?? new Uri(string.Empty, UriKind.Relative);
            var rootDir  = new DotNetDirectory(this, mountPoint, new DirectoryInfo(rootFolder), rootPath, mountPoint?.Name ?? rootPath.GetName(), true);

            Root = new AsyncLazy <ICollection>(() => Task.FromResult <ICollection>(rootDir));
        }
Beispiel #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SQLiteFileSystem"/> class.
        /// </summary>
        /// <param name="options">The options for this file system</param>
        /// <param name="mountPoint">The mount point where this file system should be included</param>
        /// <param name="connection">The SQLite database connection</param>
        /// <param name="pathTraversalEngine">The engine to traverse paths</param>
        /// <param name="lockManager">The global lock manager</param>
        /// <param name="propertyStoreFactory">The store for dead properties</param>
        public SQLiteFileSystem(
            [NotNull] SQLiteFileSystemOptions options,
            [CanBeNull] ICollection mountPoint,
            [NotNull] db::SQLiteConnection connection,
            [NotNull] IPathTraversalEngine pathTraversalEngine,
            [CanBeNull] ILockManager lockManager = null,
            [CanBeNull] IPropertyStoreFactory propertyStoreFactory = null)
        {
            RootDirectoryPath    = Path.GetDirectoryName(connection.DatabasePath);
            LockManager          = lockManager;
            _connection          = connection;
            _pathTraversalEngine = pathTraversalEngine;
            Options       = options;
            PropertyStore = propertyStoreFactory?.Create(this);
            var rootEntry = connection.Table <FileEntry>().Where(x => x.Id == string.Empty).ToList().Single();
            var rootPath  = mountPoint?.Path ?? new Uri(string.Empty, UriKind.Relative);
            var rootDir   = new SQLiteCollection(this, mountPoint, rootEntry, rootPath, mountPoint?.Name ?? rootPath.GetName(), true);

            Root = new AsyncLazy <ICollection>(() => Task.FromResult <ICollection>(rootDir));
        }
Beispiel #11
0
 public BuildOnceChainedFileSystemFactory(IOptions <ChainedFileSystemOptions> options, IPathTraversalEngine pathTraversalEngine, IServiceProvider serviceProvider, IPropertyStoreFactory propertyStoreFactory = null, ILockManager lockManager = null) : base(options, pathTraversalEngine, serviceProvider, propertyStoreFactory, lockManager)
 {
 }