Exemple #1
0
        public static void AppendFile(this IVirtualPathProvider pathProvider, string filePath, Stream stream)
        {
            var writableFs = pathProvider as IVirtualFiles;
            if (writableFs == null)
                throw new InvalidOperationException(ErrorNotWritable.Fmt(pathProvider.GetType().Name));

            writableFs.AppendFile(filePath, stream);
        }
Exemple #2
0
        public static void WriteFile(this IVirtualPathProvider pathProvider, string filePath, string textContents)
        {
            var writableFs = pathProvider as IVirtualFiles;
            if (writableFs == null)
                throw new InvalidOperationException(ErrorNotWritable.Fmt(pathProvider.GetType().Name));

            writableFs.WriteFile(filePath, textContents);
        }
Exemple #3
0
        public static void WriteFiles(this IVirtualPathProvider pathProvider, IEnumerable<IVirtualFile> srcFiles, Func<IVirtualFile, string> toPath = null)
        {
            var writableFs = pathProvider as IVirtualFiles;
            if (writableFs == null)
                throw new InvalidOperationException(ErrorNotWritable.Fmt(pathProvider.GetType().Name));

            writableFs.WriteFiles(srcFiles, toPath);
        }
Exemple #4
0
        public static void DeleteFolder(this IVirtualPathProvider pathProvider, string dirPath)
        {
            var writableFs = pathProvider as IVirtualFiles;
            if (writableFs == null)
                throw new InvalidOperationException(ErrorNotWritable.Fmt(pathProvider.GetType().Name));

            writableFs.DeleteFolder(dirPath);
        }
Exemple #5
0
        public static void DeleteFiles(this IVirtualPathProvider pathProvider, IEnumerable<IVirtualFile> files)
        {
            var writableFs = pathProvider as IVirtualFiles;
            if (writableFs == null)
                throw new InvalidOperationException(ErrorNotWritable.Fmt(pathProvider.GetType().Name));

            writableFs.DeleteFiles(files.Map(x => x.VirtualPath));
        }
        public static void AppendFile(this IVirtualPathProvider pathProvider, string filePath, Stream stream)
        {
            if (!(pathProvider is IVirtualFiles writableFs))
            {
                throw new InvalidOperationException(ErrorNotWritable.Fmt(pathProvider.GetType().Name));
            }

            writableFs.AppendFile(filePath, stream);
        }
        public static void WriteFile(this IVirtualPathProvider pathProvider, string filePath, string textContents)
        {
            if (!(pathProvider is IVirtualFiles writableFs))
            {
                throw new InvalidOperationException(ErrorNotWritable.Fmt(pathProvider.GetType().Name));
            }

            writableFs.WriteFile(filePath, textContents);
        }
        public static void WriteFiles(this IVirtualPathProvider pathProvider, Dictionary <string, string> textFiles)
        {
            if (!(pathProvider is IVirtualFiles writableFs))
            {
                throw new InvalidOperationException(ErrorNotWritable.Fmt(pathProvider.GetType().Name));
            }

            writableFs.WriteFiles(textFiles);
        }
        public static void DeleteFolder(this IVirtualPathProvider pathProvider, string dirPath)
        {
            if (!(pathProvider is IVirtualFiles writableFs))
            {
                throw new InvalidOperationException(ErrorNotWritable.Fmt(pathProvider.GetType().Name));
            }

            writableFs.DeleteFolder(dirPath);
        }
        public static void DeleteFiles(this IVirtualPathProvider pathProvider, IEnumerable <string> filePaths)
        {
            if (!(pathProvider is IVirtualFiles writableFs))
            {
                throw new InvalidOperationException(ErrorNotWritable.Fmt(pathProvider.GetType().Name));
            }

            writableFs.DeleteFiles(filePaths);
        }
Exemple #11
0
        public static void WriteFile(this IVirtualPathProvider pathProvider, string filePath, ReadOnlyMemory <byte> bytes)
        {
            if (!(pathProvider is AbstractVirtualPathProviderBase writableFs))
            {
                throw new InvalidOperationException(ErrorNotWritable.Fmt(pathProvider.GetType().Name));
            }

            writableFs.WriteFile(filePath, bytes);
        }
        public static void DeleteFiles(this IVirtualPathProvider pathProvider, IEnumerable <string> filePaths)
        {
            var writableFs = pathProvider as IWriteableVirtualPathProvider;

            if (writableFs == null)
            {
                throw new InvalidOperationException(ErrorNotWritable.Fmt(pathProvider.GetType().Name));
            }

            writableFs.DeleteFiles(filePaths);
        }
Exemple #13
0
        public static void WriteFile(this IVirtualPathProvider pathProvider, string filePath, Stream stream)
        {
            if (!(pathProvider is IVirtualFiles writableFiles))
            {
                throw new InvalidOperationException(
                          string.Format(NotWritableErrorMessage, pathProvider.GetType().Name)
                          );
            }

            writableFiles.WriteFile(filePath, stream);
        }
Exemple #14
0
        public static void WriteFile(this IVirtualPathProvider pathProvider, IVirtualFile file, string filePath = null)
        {
            var writableFs = pathProvider as IVirtualFiles;
            if (writableFs == null)
                throw new InvalidOperationException(ErrorNotWritable.Fmt(pathProvider.GetType().Name));

            using (var stream = file.OpenRead())
            {
                writableFs.WriteFile(filePath ?? file.VirtualPath, stream);
            }
        }
Exemple #15
0
        public static void AppendFile(this IVirtualPathProvider pathProvider, string filePath, byte[] bytes)
        {
            var writableFs = pathProvider as IVirtualFiles;
            if (writableFs == null)
                throw new InvalidOperationException(ErrorNotWritable.Fmt(pathProvider.GetType().Name));

            using (var ms = MemoryStreamFactory.GetStream(bytes))
            {
                writableFs.AppendFile(filePath, ms);
            }
        }
        public static void WriteFile(this IVirtualPathProvider pathProvider, string filePath, byte[] bytes)
        {
            if (!(pathProvider is IVirtualFiles writableFs))
            {
                throw new InvalidOperationException(ErrorNotWritable.Fmt(pathProvider.GetType().Name));
            }

            using (var ms = MemoryStreamFactory.GetStream(bytes))
            {
                writableFs.WriteFile(filePath, ms);
            }
        }