public void Extract(Assembly assembly, string prefix, string outputDirectory) { Directory.CreateDirectory(outputDirectory); foreach (var subDir in this.knownSubDirectories.Select(s => s.Value)) { Directory.CreateDirectory(Path.Combine(outputDirectory, subDir)); } foreach (string resourceName in assembly.GetManifestResourceNames().Where(r => r.StartsWith(prefix, StringComparison.Ordinal))) { string filename = resourceName.Substring(prefix.Length); string subDirKey = this.knownSubDirectories.Keys .Where(k => filename.StartsWith(k, StringComparison.Ordinal)) .OrderByDescending(p => p.Length) // This ensures we get the most qualified prefix .FirstOrDefault(); if (subDirKey != null) { filename = Path.Combine(this.knownSubDirectories[subDirKey], filename.Substring(subDirKey.Length)); } filename = Path.Combine(outputDirectory, filename); IOHelpers.WriteResourceToFile(resourceName, filename, assembly); } }
private static List <string> FindFilePaths(IEnumerable <string> directories, string assemblyName) { #if !SILVERLIGHT return(directories.Select(d => Path.Combine(d, assemblyName)).Where(f => IOHelpers.FileExists(f)).ToList()); #else return(new List <string>()); #endif }
/// <summary> /// Initializes a new instance of the AssemblyPathResolver class. /// </summary> public AssemblyPathResolver() { #if !SILVERLIGHT && !WIN8 this.TempAssemblyDirectory = IOHelpers.CreateTempDirectory("CompiledAsemblies"); #else #if WIN8 this.TempAssemblyDirectory = @"C:\Users\mfrintu\Documents\CompiledAssemblies"; #endif #endif }
public static void ExtractResourceToDirectory(string outputDirectory, Assembly assembly, string resourceName, string fileName) { ValidateCommonArguments(outputDirectory, assembly, resourceName); fileName = fileName ?? resourceName; string fullResourceName = new AssemblyName(assembly.FullName).Name + ".Resources." + resourceName; using (Stream inputStream = assembly.GetManifestResourceStream(fullResourceName)) { if (inputStream == null) { throw new TaupoInfrastructureException("Embedded resource " + fullResourceName + " not found in " + assembly.FullName); } using (Stream outputStream = File.Create(Path.Combine(outputDirectory, fileName))) { IOHelpers.CopyStream(inputStream, outputStream); } } }
public static void ExtractCompressedResourceToDirectory(string outputDirectory, Assembly assembly, string resourceName) { ValidateCommonArguments(outputDirectory, assembly, resourceName); string fullResourceName = new AssemblyName(assembly.FullName).Name + ".Resources." + resourceName + ".gz"; using (Stream compressedInputStream = assembly.GetManifestResourceStream(fullResourceName)) { if (compressedInputStream == null) { throw new TaupoInfrastructureException("Embedded resource " + fullResourceName + " not found in " + assembly.FullName); } using (GZipStream decompressedInputStream = new GZipStream(compressedInputStream, CompressionMode.Decompress)) { using (Stream outputStream = File.Create(Path.Combine(outputDirectory, resourceName))) { IOHelpers.CopyStream(decompressedInputStream, outputStream); } } } }
/// <summary> /// Initializes a new instance of the DefaultWorkspaceManager class. /// </summary> /// <param name="baseDirectory">The base directory for workspaces.</param> public DefaultWorkspaceManager(string baseDirectory) { this.BaseDirectory = IOHelpers.GetFullPath(baseDirectory); this.Logger = Logger.Null; }
private bool IsAvailable(string proposedName) { return(!IOHelpers.DirectoryExists(this.GetWorkspacePath(proposedName))); }
private static List <string> FindFilePaths(IEnumerable <string> directories, string assemblyName) { return(directories.Select(d => Path.Combine(d, assemblyName)).Where(f => IOHelpers.FileExists(f)).ToList()); }
/// <summary> /// Initializes a new instance of the AssemblyPathResolver class. /// </summary> public AssemblyPathResolver() { this.TempAssemblyDirectory = IOHelpers.CreateTempDirectory("CompiledAsemblies"); }