LibHac/tests/LibHac.Tests/Fs/FileSystemClientTests/FileSystemServerFactory.cs
Alex Barney 071b608f5f Tweak how the Horizon class and service manager work
- Store IServiceObjects in the service manager that return the usable objects instead of storing the objects directly
- Register FS services in the service manager instead of giving them special treatment
- Give each created HorizonClient its own "process ID"
2020-08-26 17:10:12 -07:00

39 lines
1.2 KiB
C#

using LibHac.Fs;
using LibHac.Fs.Fsa;
using LibHac.FsSrv;
namespace LibHac.Tests.Fs.FileSystemClientTests
{
public static class FileSystemServerFactory
{
private static FileSystemClient CreateClientImpl(bool sdCardInserted, out IFileSystem rootFs)
{
rootFs = new InMemoryFileSystem();
var defaultObjects = DefaultFsServerObjects.GetDefaultEmulatedCreators(rootFs, new Keyset());
defaultObjects.SdCard.SetSdCardInsertionStatus(sdCardInserted);
var config = new FileSystemServerConfig();
config.FsCreators = defaultObjects.FsCreators;
config.DeviceOperator = defaultObjects.DeviceOperator;
config.ExternalKeySet = new ExternalKeySet();
var horizon = new Horizon(new StopWatchTimeSpanGenerator(), config);
HorizonClient horizonClient = horizon.CreateHorizonClient();
return horizonClient.Fs;
}
public static FileSystemClient CreateClient(bool sdCardInserted)
{
return CreateClientImpl(sdCardInserted, out _);
}
public static FileSystemClient CreateClient(out IFileSystem rootFs)
{
return CreateClientImpl(false, out rootFs);
}
}
}