Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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
        }
Ejemplo n.º 3
0
        /// <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
        }
Ejemplo n.º 4
0
        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);
                }
            }
        }
Ejemplo n.º 5
0
        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);
                    }
                }
            }
        }
Ejemplo n.º 6
0
 /// <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;
 }
Ejemplo n.º 7
0
 private bool IsAvailable(string proposedName)
 {
     return(!IOHelpers.DirectoryExists(this.GetWorkspacePath(proposedName)));
 }
Ejemplo n.º 8
0
 private static List <string> FindFilePaths(IEnumerable <string> directories, string assemblyName)
 {
     return(directories.Select(d => Path.Combine(d, assemblyName)).Where(f => IOHelpers.FileExists(f)).ToList());
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the AssemblyPathResolver class.
 /// </summary>
 public AssemblyPathResolver()
 {
     this.TempAssemblyDirectory = IOHelpers.CreateTempDirectory("CompiledAsemblies");
 }