/// <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 DirectDotNetFileSystemFactory(
     IOptions <DotNetFileSystemOptions> options,
     IPathTraversalEngine pathTraversalEngine,
     IPropertyStoreFactory propertyStoreFactory = null,
     ILockManager lockManager = null)
 {
     _pathTraversalEngine  = pathTraversalEngine;
     _propertyStoreFactory = propertyStoreFactory;
     _lockManager          = lockManager;
     _options = options.Value;
 }
示例#2
0
        public DotNetFileSystemServices()
        {
            var serviceCollection = new ServiceCollection()
                                    .AddOptions()
                                    .AddLogging()
                                    .Configure <InMemoryLockManagerOptions>(opt =>
            {
                opt.Rounding = new DefaultLockTimeRounding(DefaultLockTimeRoundingMode.OneHundredMilliseconds);
            })
                                    .AddScoped <ILockManager, InMemoryLockManager>()
                                    .AddScoped <IDeadPropertyFactory, DeadPropertyFactory>()
                                    .AddScoped <IWebDavContext>(sp => new TestHost(sp, new Uri("http://localhost/")))
                                    .AddScoped <IFileSystemFactory>(
                sp =>
            {
                var tempRootPath = Path.Combine(
                    Path.GetTempPath(),
                    "webdavserver-dotnet-tests",
                    Guid.NewGuid().ToString("N"));
                Directory.CreateDirectory(tempRootPath);
                _tempDbRootPaths.Add(tempRootPath);

                var opt = new DotNetFileSystemOptions
                {
                    RootPath = tempRootPath,
                };
                var pte = sp.GetRequiredService <IPathTraversalEngine>();
                var psf = sp.GetService <IPropertyStoreFactory>();
                var lm  = sp.GetService <ILockManager>();

                var fsf = new DotNetFileSystemFactory(
                    new OptionsWrapper <DotNetFileSystemOptions>(opt),
                    pte,
                    psf,
                    lm);
                return(fsf);
            })
                                    .AddSingleton <IPropertyStoreFactory, InMemoryPropertyStoreFactory>()
                                    .AddWebDav();

            ServiceProvider = serviceCollection.BuildServiceProvider();

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

            loggerFactory.AddDebug(LogLevel.Trace);
        }
        public ServerManagerFileSystemProvider(IOptions <DotNetFileSystemOptions> options,
                                               IAccountDirectoryQuery accountDirectoryQuery,
                                               ILogger <ServerManagerFileSystemProvider> logger,
                                               IServiceProvider serviceProvider)
        {
            _accountDirectoryQuery = accountDirectoryQuery;
            _logger          = logger;
            _options         = options.Value;
            _serviceProvider = serviceProvider;

            _rootPath = string.IsNullOrEmpty(options.Value.RootPath)
                ? Path.GetTempPath()
                : options.Value.RootPath !;
            _streamBufferSize             = options.Value.StreamBufferSize ?? DotNetFileSystem.DefaultStreamBufferSize;
            _allowNonEmptyDirectoryDelete = options.Value.AllowNonEmptyDirectoryDelete;
            //_flushAfterWrite = options.Value;
        }