コード例 #1
0
 public void WriteFile(string filePath, Func<Stream> fileContentStream)
 {
     int index = filePath.IndexOf(DirectorySeparator, StringComparison.Ordinal);
     if (index == -1)
     {
         VirtualFileSystemFile file = new VirtualFileSystemFile(filePath, fileContentStream);
         AddFile(file);
         return;
     }
     string subDirectory = filePath.Substring(0, index);
     string subDirectoryFilePath = filePath.Substring(index + DirectorySeparator.Length,
         filePath.Length - index - DirectorySeparator.Length);
     var existingSubDirectory = _directories.SingleOrDefault(d => d.Name == subDirectory);
     if (existingSubDirectory == null)
     {
         existingSubDirectory = new VirtualFileSystemDirectory(subDirectory);
         AddDirectory(existingSubDirectory);
     }
     existingSubDirectory.WriteFile(subDirectoryFilePath, fileContentStream);
 }
コード例 #2
0
 public void AddDirectory(VirtualFileSystemDirectory directory)
 {
     _directories.Add(directory);
 }