public void Add(Assembly assembly) { var assemblyName = assembly.GetName().Name; foreach (var resourcePath in assembly.GetManifestResourceNames()) { var virtualPath = resourcePath; if (ExcludeAssemblyNameFromPath && resourcePath.StartsWith(assemblyName)) { virtualPath = resourcePath.Substring(assemblyName.Length).TrimStart('.'); } var tokens = virtualPath.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries); if (tokens.Length > 1) // Handle file extension { var extension = tokens.Last(); tokens = tokens.Take(tokens.Length - 1).ToArray(); tokens[tokens.Length - 1] += "." + extension; } virtualPath = this.VirtualPathSeparator + tokens.Aggregate((a, b) => CombineVirtualPath(a, b)); if (Resources.ContainsKey(virtualPath)) throw new ArgumentException(String.Format("Some resources use the same key: {0}", resourcePath)); Resources[virtualPath] = new EmbeddedResource(assembly, resourcePath, virtualPath); } }
public EmbeddedResourceVirtualFile(EmbeddedResourceVirtualPathProvider owningProvider, EmbeddedResourceVirtualDirectory directory, EmbeddedResource embedded) : base(owningProvider, directory) { if (embedded == null) { throw new ArgumentNullException("embedded"); } Embedded = embedded; this.Provider = owningProvider; }