Created
May 1, 2020 12:49
-
-
Save TheFo2sh/acac085bffa73fa6df8eac409564bef7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class FileSystemBase | |
{ | |
protected Dictionary<string, File> _cachedFiles; | |
protected FileSystemBase() | |
{ | |
_cachedFiles = new Dictionary<string, File>(); | |
} | |
public abstract File CreateFile(string filename); | |
public abstract void DeleteFile(string filename); | |
public abstract File GetFile(string filename); | |
public File GetOrCreateFile(string filename) | |
{ | |
var file = GetFile(filename); | |
if (file == null) | |
file = CreateFile(filename); | |
return file; | |
} | |
public File GetFileCached(string filename) | |
{ | |
if (!_cachedFiles.ContainsKey(filename)) | |
{ | |
_cachedFiles.Add(filename,GetFile(filename)); | |
} | |
return _cachedFiles[filename]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment