public InMemoryVirtualDirectory(IVirtualPathProvider owningProvider, IVirtualDirectory parentDirectory) : base(owningProvider, parentDirectory) { this.files = new List <InMemoryVirtualFile>(); this.dirs = new List <InMemoryVirtualDirectory>(); this.DirLastModified = DateTime.MinValue; }
public AzureBlobVirtualFile(AzureBlobVirtualPathProvider owningProvider, IVirtualDirectory directory) : base(owningProvider, directory) { this.pathProvider = owningProvider; this.container = pathProvider.Container; }
public static void Load(IVirtualDirectory svgDir) { var context = new ScriptContext().Init(); foreach (var svgGroupDir in svgDir.GetDirectories()) { foreach (var file in svgGroupDir.GetFiles()) { if (file.Extension == "svg") { var svg = file.ReadAllText(); AddImage(svg, file.Name.WithoutExtension(), svgGroupDir.Name); } else if (file.Extension == "html") { var script = file.ReadAllText(); var svg = context.EvaluateScript(script); if (svg.StartsWith("<svg")) { AddImage(svg, file.Name.WithoutExtension(), svgGroupDir.Name); } else { log.Warn($"Unable to load #Script SVG '{file.Name}'"); } } } } }
public InMemoryVirtualDirectory(IVirtualPathProvider owningProvider, IVirtualDirectory parentDirectory) : base(owningProvider, parentDirectory) { this.files = new List<InMemoryVirtualFile>(); this.dirs = new List<InMemoryVirtualDirectory>(); this.DirLastModified = DateTime.MinValue; }
/// <summary>Initializes a new instance of the NServiceKit.VirtualPath.EmbeddedResourceVirtualPathProvider.StreamBasedVirtualFile class.</summary> /// /// <param name="owningProvider">The owning provider.</param> /// <param name="directory"> Pathname of the directory.</param> /// <param name="contents"> The contents.</param> /// <param name="name"> The name.</param> /// <param name="lastModified"> The last modified.</param> public StreamBasedVirtualFile(IVirtualPathProvider owningProvider, IVirtualDirectory directory, Stream contents, string name, DateTime lastModified) : base(owningProvider, directory) { _contents = contents; _name = name; _lastModified = lastModified; FilePath = name; }
public string GetTemplatePath(IVirtualDirectory fileDir) { try { if (templatePathsNotFound.Contains(fileDir.VirtualPath)) return null; var templateDir = fileDir; IVirtualFile templateFile; while (templateDir != null && templateDir.GetFile(defaultTemplateName) == null) { if (templatePathsFound.TryGetValue(templateDir.VirtualPath, out templateFile)) return templateFile.RealPath; templateDir = templateDir.ParentDirectory; } if (templateDir != null) { templateFile = templateDir.GetFile(defaultTemplateName); templatePathsFound[templateDir.VirtualPath] = templateFile; return templateFile.VirtualPath; } templatePathsNotFound.Add(fileDir.VirtualPath); return null; } catch (Exception ex) { ex.Message.Print(); throw; } }
public static IVirtualFile CopyFile(this IVirtualDirectory directory, IVirtualFile file, string name) { // TODO: use stream to stream copy (need AddFile out stream) var contents = file.ReadAllBytes(); return(directory.CreateFile(name, contents)); }
public void setup() { _provider = new DirectoryVirtualFileProvider(); _root = MockRepository.GenerateMock<IVirtualDirectory>(); _provider.Setup(_root); }
protected override IVirtualFile MoveBackingFileToDirectory(IVirtualDirectory directory, string name) { var newFile = directory.CopyFile(this, name); this.Delete(); return(newFile); }
public FileSystemVirtualDirectory(IVirtualPathProvider owningProvider, IVirtualDirectory parentDirectory, DirectoryInfo dInfo) : base(owningProvider, parentDirectory) { if (dInfo == null) throw new ArgumentNullException("dInfo"); this.BackingDirInfo = dInfo; }
public SftpVirtualFile(SftpVirtualPathProvider owningProvider, IVirtualDirectory directory, string name, DateTime?lastModified) : base(owningProvider, directory) { this.Provider = owningProvider; this._name = name; this._lastModified = lastModified ?? DateTime.MinValue; this.File = new Lazy <SftpFile>(() => _file ?? Provider.GetSftpFile(this.VirtualPath)); }
public SftpVirtualDirectory(SftpVirtualPathProvider owningProvider, IVirtualDirectory parentDirectory, String name = null, DateTime?lastModified = null) : base(owningProvider, parentDirectory) { this.Provider = owningProvider; _name = name; _lastModified = lastModified ?? DateTime.MinValue; }
public FileSystemVirtualFile(IVirtualPathProvider owningProvider, IVirtualDirectory directory, FileInfo fInfo) : base(owningProvider, directory) { if (fInfo == null) throw new ArgumentNullException("fInfo"); this.BackingFile = fInfo; }
public FileSystemVirtualDirectory( IVirtualPathProvider owningProvider, IVirtualDirectory parentDirectory, DirectoryInfo directoryInfo) : base(owningProvider, parentDirectory) { BackingDirectoryInfo = directoryInfo; }
/// <summary> /// /// </summary> /// <param name="owningProvider"></param> /// <param name="parentDirectory"></param> public InMemoryVirtualDirectory(IVirtualPathProvider owningProvider, IVirtualDirectory parentDirectory) : base(owningProvider, parentDirectory) { files = new List <InMemoryVirtualFile>(); dirs = new List <InMemoryVirtualDirectory>(); DirLastModified = DateTime.MinValue; FlattenFileEnumeration = true; }
protected VirtualFile(IVirtualPathProvider owningProvider, IVirtualDirectory directory) { EnsureArg.IsNotNull(owningProvider, nameof(owningProvider)); EnsureArg.IsNotNull(directory, nameof(directory)); VirtualPathProvider = owningProvider; Directory = directory; }
public SftpVirtualFile(SftpVirtualPathProvider owningProvider, IVirtualDirectory directory, string name, DateTime? lastModified) : base(owningProvider, directory) { this.Provider = owningProvider; this._name = name; this._lastModified = lastModified ?? DateTime.MinValue; this.File = new Lazy<SftpFile>(() => _file ?? Provider.GetSftpFile(this.VirtualPath)); }
public SftpVirtualDirectory(SftpVirtualPathProvider owningProvider, IVirtualDirectory parentDirectory, String name = null, DateTime? lastModified = null) : base(owningProvider, parentDirectory) { this.Provider = owningProvider; _name = name; _lastModified = lastModified ?? DateTime.MinValue; }
protected VirtualDirectory(IVirtualPathProvider owningProvider, IVirtualDirectory parentDirectory) { EnsureArg.IsNotNull(owningProvider, nameof(owningProvider)); EnsureArg.IsNotNull(parentDirectory, nameof(parentDirectory)); VirtualPathProvider = owningProvider; ParentDirectory = parentDirectory; }
protected AbstractVirtualDirectoryBase(IVirtualPathProvider owningProvider, IVirtualDirectory parentDirectory) { if (owningProvider == null) throw new ArgumentNullException("owningProvider"); this.VirtualPathProvider = owningProvider; this.ParentDirectory = parentDirectory; }
public void setup() { var dir = new DirectoryInfo(@"E:\Develop\FLUX\DATA\XMLSourceProviderSource"); Assert.That(dir.Exists, Is.True); _root = new RealDirectory(dir); _provider = new AbstractVirtualPoviderSub(); _provider.Setup(_root); }
private void ResolveDirectoryRecursive(IVirtualDirectory directory, string glob, List <IVirtualFile> matchedFiles) { matchedFiles.AddRange(directory.Files.Where(file => file.VirtualPath.Glob(glob))); foreach (var dir in directory.Directories) { ResolveDirectoryRecursive(dir, glob, matchedFiles); } }
public ResourceVirtualDirectory(IVirtualPathProvider owningProvider, IVirtualDirectory parentDir, Assembly backingAsm, string rootNamespace) : this(owningProvider, parentDir, backingAsm, rootNamespace, rootNamespace, GetResourceNames(backingAsm, rootNamespace)) { }
protected AbstractVirtualDirectoryBase(IVirtualPathProvider owningProvider, IVirtualDirectory parentDirectory) { if (owningProvider == null) { throw new ArgumentNullException("owningProvider"); } this.VirtualPathProvider = owningProvider; this.ParentDirectory = parentDirectory; }
public FileSystemVirtualFile( IVirtualPathProvider owningProvider, IVirtualDirectory directory, FileInfo fileInfo) : base(owningProvider, directory) { EnsureArg.IsNotNull(fileInfo, nameof(fileInfo)); BackingFileInfo = fileInfo; }
public FileSystemVirtualFile(IVirtualPathProvider owningProvider, IVirtualDirectory parentDirectory, FileInfo fInfo) : base(owningProvider, parentDirectory) { if (fInfo == null) { throw new ArgumentNullException("fInfo"); } this.BackingFile = fInfo; }
protected AbstractVirtualFileBase( IVirtualPathProvider owningProvider, IVirtualDirectory directory) { if (owningProvider == null) throw new ArgumentNullException("owningProvider"); if (directory == null) throw new ArgumentNullException("directory"); this.VirtualPathProvider = owningProvider; this.Directory = directory; }
private int[] getCounts(IVirtualDirectory subroot, int[] subRoots) { var index = subroot.GetFile("Index.xml"); XmlSerializer ser = new XmlSerializer(typeof(Root)); var o = ser.Deserialize(index.Open()); var root = o as Root; if (subRoots == null || subRoots.Length == 0) subRoots = Enumerable.Range(0, root.Groups).ToArray(); return subRoots; }
protected override IVirtualFile CopyBackingFileToDirectory(IVirtualDirectory directory, string name) { if (directory is FileSystemVirtualDirectory) { var copyFInfo = BackingFile.CopyTo(Path.Combine(directory.RealPath, name), true); return new FileSystemVirtualFile(VirtualPathProvider, directory, copyFInfo); } else { return directory.CopyFile(this, name); } }
protected override IVirtualFile CopyBackingFileToDirectory(IVirtualDirectory directory, string name) { if (directory is FileSystemVirtualDirectory) { var copyFInfo = BackingFile.CopyTo(Path.Combine(directory.RealPath, name), true); return(new FileSystemVirtualFile(VirtualPathProvider, directory, copyFInfo)); } else { return(directory.CopyFile(this, name)); } }
protected override IVirtualFile MoveBackingFileToDirectory(IVirtualDirectory directory, string name) { if (directory is FileSystemVirtualDirectory) { BackingFile.MoveTo(Path.Combine(directory.RealPath, name)); return new FileSystemVirtualFile(VirtualPathProvider, directory, BackingFile); } else { var newFile = directory.CopyFile(this, name); this.Delete(); return newFile; } }
public ResourceVirtualDirectory(IVirtualPathProvider owningProvider, IVirtualDirectory parentDir, Assembly backingAsm, String directoryName, IEnumerable<String> manifestResourceNames) : base(owningProvider, parentDir) { if (backingAsm == null) throw new ArgumentNullException("backingAsm"); if (string.IsNullOrEmpty(directoryName)) throw new ArgumentException("directoryName"); this.backingAssembly = backingAsm; this.DirectoryName = directoryName; InitializeDirectoryStructure(manifestResourceNames); }
protected override IVirtualFile MoveBackingFileToDirectory(IVirtualDirectory directory, string name) { if (directory is FileSystemVirtualDirectory) { BackingFile.MoveTo(Path.Combine(directory.RealPath, name)); return(new FileSystemVirtualFile(VirtualPathProvider, directory, BackingFile)); } else { var newFile = directory.CopyFile(this, name); this.Delete(); return(newFile); } }
public static IVirtualFile GetDefaultDocument(this IVirtualDirectory dir) { foreach (var defaultDoc in HostContext.Config.DefaultDocuments) { var defaultFile = dir.GetFile(defaultDoc); if (defaultFile == null) { continue; } return(defaultFile); } return(null); }
/// <summary> /// Get All Files in current and all sub directories /// </summary> /// <param name="dir"></param> /// <returns></returns> public static IEnumerable <IVirtualFile> GetAllFiles(this IVirtualDirectory dir) { foreach (var subDir in dir.GetDirectories()) { foreach (var file in subDir.GetAllFiles()) { yield return(file); } } foreach (var file in dir.Files) { yield return(file); } }
public static IVirtualFile GetDefaultDocument(this IVirtualDirectory dir, List <string> defaultDocuments) { foreach (var defaultDoc in defaultDocuments) { var defaultFile = dir.GetFile(defaultDoc); if (defaultFile == null) { continue; } return(defaultFile); } return(null); }
protected override IVirtualFile CopyBackingFileToDirectory(IVirtualDirectory directory, string name) { if (directory is DropboxVirtualDirectory) { var dir = (DropboxVirtualDirectory)directory; if (dir.Provider == this.Provider) { Provider.Copy(this.VirtualPath, Provider.CombineVirtualPath(directory.VirtualPath, name)); return new DropboxVirtualFile(Provider, dir, name); } } // TODO: copy cross Dropboxes using CopyRef? return directory.CopyFile(this, name); }
protected AbstractVirtualFileBase( IVirtualPathProvider owningProvider, IVirtualDirectory directory) { if (owningProvider == null) { throw new ArgumentNullException("owningProvider"); } if (directory == null) { throw new ArgumentNullException("directory"); } this.VirtualPathProvider = owningProvider; this.Directory = directory; }
protected override IVirtualFile CopyBackingFileToDirectory(IVirtualDirectory directory, string name) { if (directory is DropboxVirtualDirectory) { var dir = (DropboxVirtualDirectory)directory; if (dir.Provider == this.Provider) { Provider.Copy(this.VirtualPath, Provider.CombineVirtualPath(directory.VirtualPath, name)); return(new DropboxVirtualFile(Provider, dir, name)); } } // TODO: copy cross Dropboxes using CopyRef? return(directory.CopyFile(this, name)); }
internal IVirtualFile Move(FtpVirtualFile source, IVirtualDirectory destination, string destFilename) { if (destination.VirtualPathProvider == this) { var destPath = this.CombineVirtualPath(destination.VirtualPath, destFilename); this.ConnectedClient.RenameFile(source.VirtualPath, destPath); this.nodes.Remove(NormalizeAbsolutePath(source.VirtualPath)); return(this.GetOrAddFile(destPath)); } else { var copy = source.CopyTo(destination, destFilename); source.Delete(); return(copy); } }
public static void Load(IVirtualDirectory svgDir) { if (svgDir == null) { throw new ArgumentNullException(nameof(svgDir)); } var context = new ScriptContext { ScriptBlocks = { new SvgScriptBlock() } }.Init(); foreach (var svgGroupDir in svgDir.GetDirectories()) { foreach (var file in svgGroupDir.GetFiles()) { if (file.Extension == "svg") { var svg = file.ReadAllText(); AddImage(svg, file.Name.WithoutExtension(), svgGroupDir.Name); } else if (file.Extension == "html") { var script = file.ReadAllText(); var svg = context.EvaluateScript(script); if (svg.StartsWith("<svg")) { AddImage(svg, file.Name.WithoutExtension(), svgGroupDir.Name); } else { log.Warn($"Unable to load #Script SVG '{file.Name}'"); } } } } // Also load any .html #Script files which can register svg using {{#svg name group}} #Script block foreach (var svgScript in svgDir.GetAllMatchingFiles("*.html")) { var script = svgScript.ReadAllText(); var output = context.EvaluateScript(script); } }
protected override IVirtualFile MoveBackingFileToDirectory(IVirtualDirectory directory, string name) { if (directory is SftpVirtualDirectory) { var dir = (SftpVirtualDirectory)directory; if (dir.Provider == this.Provider) { ((SftpVirtualDirectory)this.Directory).RemoveFromCache(this); File.Value.MoveTo(Provider.CombineVirtualPath(directory.VirtualPath, name)); return new SftpVirtualFile(Provider, dir, name, DateTime.Now); } } var newFile = directory.CopyFile(this, name); this.Delete(); return newFile; }
public ResourceVirtualDirectory(IVirtualPathProvider owningProvider, IVirtualDirectory parentDir, Assembly backingAsm, String directoryName, IEnumerable <String> manifestResourceNames) : base(owningProvider, parentDir) { if (backingAsm == null) { throw new ArgumentNullException("backingAsm"); } if (string.IsNullOrEmpty(directoryName)) { throw new ArgumentException("directoryName"); } this.backingAssembly = backingAsm; this.DirectoryName = directoryName; InitializeDirectoryStructure(manifestResourceNames); }
protected override IVirtualFile MoveBackingFileToDirectory(IVirtualDirectory directory, string name) { if (directory is DropboxVirtualDirectory) { var dir = (DropboxVirtualDirectory)directory; if (dir.Provider == this.Provider) { Provider.Move(this.VirtualPath, Provider.CombineVirtualPath(directory.VirtualPath, name)); ((DropboxVirtualDirectory)Directory).RemoveFromContents(this); return(new DropboxVirtualFile(Provider, dir, name)); } } var newFile = directory.CopyFile(this, name); this.Delete(); return(newFile); }
protected override IVirtualFile MoveBackingFileToDirectory(IVirtualDirectory directory, string name) { if (directory is FtpVirtualDirectory) { var dir = (FtpVirtualDirectory)directory; if (dir.Provider == this.Provider) { var currentDir = (FtpVirtualDirectory)this.Directory; currentDir.RemoveFromContents(this.Name); Provider.Rename(this.VirtualPath, Provider.CombineVirtualPath(dir.VirtualPath, name)); return new FtpVirtualFile(Provider, dir, name, DateTime.Now); } } var newFile = directory.CopyFile(this, name); this.Delete(); return newFile; }
protected override IVirtualFile MoveBackingFileToDirectory(IVirtualDirectory directory, string name) { if (directory is SftpVirtualDirectory) { var dir = (SftpVirtualDirectory)directory; if (dir.Provider == this.Provider) { ((SftpVirtualDirectory)this.Directory).RemoveFromCache(this); File.Value.MoveTo(Provider.CombineVirtualPath(directory.VirtualPath, name)); return(new SftpVirtualFile(Provider, dir, name, DateTime.Now)); } } var newFile = directory.CopyFile(this, name); this.Delete(); return(newFile); }
public ResourceVirtualDirectory(IVirtualPathProvider owningProvider, IVirtualDirectory parentDir, Assembly backingAsm, string rootNamespace, string directoryName, List<string> manifestResourceNames) : base(owningProvider, parentDir) { if (backingAsm == null) throw new ArgumentNullException(nameof(backingAsm)); if (string.IsNullOrEmpty(directoryName)) throw new ArgumentNullException(nameof(directoryName)); this.backingAssembly = backingAsm; this.rootNamespace = rootNamespace; this.DirectoryName = directoryName; InitializeDirectoryStructure(manifestResourceNames); }
public Dictionary<int, IVirtualFile> BuildVirtualFiles(IVirtualDirectory root, string name, int[] subRoots) { var subrootDir = root.GetDirectory(name); subRoots = getCounts(subrootDir, subRoots); XmlSerializer ser = new XmlSerializer(typeof(Group)); var dict = new Dictionary<int, IVirtualFile>(); foreach (var subroot in subRoots) { var fs = subrootDir.GetFile(subroot + ".xml").Open(); if (fs == null) continue; var group = ser.Deserialize(fs) as Group; if (group == null) continue; foreach (var item in group.Source.Items) { dict.Add(item.ID, item); } } return dict; }
public Dictionary<int, IVirtualFile> BuildVirtualFiles(IVirtualDirectory root, string name, int[] subRoots) { // read directory by name // dir == artist var dir = root.GetDirectory(name); Dictionary<int, IVirtualFile> result = new Dictionary<int, IVirtualFile>(); // get alben // iteriere erst über die dirs // wähle die deren position in subroots enthalten ist int pos = -1; int arrayPos = 0; foreach (var subdir in dir.GetDirectories()) { pos++; if (subRoots != null) { if (arrayPos < subRoots.Length) { if (pos == subRoots[arrayPos]) { arrayPos++; } else continue; } else continue; } foreach (var virtualFile in subdir.GetFiles("*.mp3", SearchOption.AllDirectories, c => (pos + 1) * 1000 + c)) { result.Add(virtualFile.ID, virtualFile); } } return result; }
public void AssertContents(IVirtualDirectory dir, string[] expectedFilePaths, string[] expectedDirPaths) { var filePaths = dir.Files.Map(x => x.VirtualPath); Assert.IsTrue(filePaths == expectedFilePaths.ToList()); var fileNames = dir.Files.Map(x => x.Name); Assert.IsTrue(fileNames == expectedFilePaths.Map(x => x.SplitOnLast('/').Last())); var dirPaths = dir.Directories.Map(x => x.VirtualPath); Assert.IsTrue(dirPaths == expectedDirPaths.ToList()); var dirNames = dir.Directories.Map(x => x.Name); Assert.IsTrue(dirNames == expectedDirPaths.Map(x => x.SplitOnLast('/').Last())); }
public void AssertContents(IVirtualDirectory dir, string[] expectedFilePaths, string[] expectedDirPaths) { var filePaths = dir.Files.Map(x => x.VirtualPath); Assert.That(filePaths, Is.EquivalentTo(expectedFilePaths)); var fileNames = dir.Files.Map(x => x.Name); Assert.That(fileNames, Is.EquivalentTo(expectedFilePaths.Map(x => x.SplitOnLast('/').Last()))); var dirPaths = dir.Directories.Map(x => x.VirtualPath); Assert.That(dirPaths, Is.EquivalentTo(expectedDirPaths)); var dirNames = dir.Directories.Map(x => x.Name); Assert.That(dirNames, Is.EquivalentTo(expectedDirPaths.Map(x => x.SplitOnLast('/').Last()))); }
private void ResolveDirectoryRecursive(IVirtualDirectory directory, string glob, List<IVirtualFile> matchedFiles) { matchedFiles.AddRange(directory.Files.Where(file => file.VirtualPath.Glob(glob))); foreach (var dir in directory.Directories) { ResolveDirectoryRecursive(dir, glob, matchedFiles); } }
public InMemoryVirtualDirectory(IVirtualPathProvider owningProvider, IVirtualDirectory parentDirectory) : base(owningProvider, parentDirectory) {}
public InMemoryVirtualFile(IVirtualPathProvider owningProvider, IVirtualDirectory directory) : base(owningProvider, directory) { this.FileLastModified = DateTime.MinValue; }
/// <summary> /// /// </summary> /// <param name="owningProvider"></param> /// <param name="parentDirectory"></param> public InMemoryVirtualDirectory(IVirtualPathProvider owningProvider, IVirtualDirectory parentDirectory) : base(owningProvider, parentDirectory) { files = new List<InMemoryVirtualFile>(); dirs = new List<InMemoryVirtualDirectory>(); DirLastModified = DateTime.MinValue; FlattenFileEnumeration = true; }
public void Setup(IVirtualDirectory root) { Root = root; }
public ResourceVirtualDirectory(IVirtualPathProvider owningProvider, IVirtualDirectory parentDir, Assembly backingAsm) : this(owningProvider, parentDir, backingAsm, backingAsm.GetName().Name, backingAsm.GetManifestResourceNames()) { }