Files
csharp/src/KubernetesClient/FileUtils.cs

35 lines
813 B
C#
Raw Normal View History

using System;
using System.IO.Abstractions;
namespace k8s
{
public static class FileUtils
{
private static IFileSystem realFileSystem = new FileSystem();
private static IFileSystem currentFileSystem = null;
public static void InjectFilesystem(IFileSystem fs)
{
currentFileSystem = fs;
}
public static IFileSystem FileSystem()
{
return currentFileSystem != null ? currentFileSystem : realFileSystem;
}
public sealed class InjectedFileSystem : IDisposable
{
public InjectedFileSystem(IFileSystem fs)
{
InjectFilesystem(fs);
}
public void Dispose()
{
InjectFilesystem(null);
}
}
}
}