-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegisterDatabaseFileSystemExtensions.cs
More file actions
29 lines (26 loc) · 1.03 KB
/
Copy pathRegisterDatabaseFileSystemExtensions.cs
File metadata and controls
29 lines (26 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using DryIoc;
using SquidStd.Database.Abstractions.Interfaces.Data;
using SquidStd.Vfs.Abstractions.Interfaces;
using SquidStd.Vfs.Database.Data.Entities;
using SquidStd.Vfs.Database.Services;
namespace SquidStd.Vfs.Database.Extensions;
/// <summary>DryIoc registration helper for the database VFS backend.</summary>
public static class RegisterDatabaseFileSystemExtensions
{
/// <param name="container">Container that receives the VFS registration.</param>
extension(IContainer container)
{
/// <summary>
/// Registers an <see cref="IVirtualFileSystem" /> backed by the database.
/// Requires the SquidStd.Database module to be registered (it supplies <c>IDataAccess<></c>).
/// </summary>
public IContainer RegisterDatabaseFileSystem()
{
container.RegisterDelegate<IVirtualFileSystem>(
r => new DatabaseFileSystem(r.Resolve<IDataAccess<VfsFileEntity>>()),
Reuse.Singleton
);
return container;
}
}
}