/// <summary> /// Add a namespace mapping for embedded resources. /// </summary> /// <param name="mapping"> Mapping to add </param> public void Add(NamespaceMapping mapping) { if (mapping == null) throw new ArgumentNullException("mapping"); Map(mapping); }
private void Map(NamespaceMapping mapping) { var names = mapping.Assembly.GetManifestResourceNames(); foreach (var name in names) { if (!name.StartsWith(mapping.FolderNamespace)) continue; _resourceNames.Add(new MappedResource { Assembly = mapping.Assembly, AssemblyDate = new FileInfo(mapping.Assembly.Location).CreationTimeUtc, FullResourceName = name, ResourceRoot = mapping.FolderNamespace, ResourceName = name.Remove(0, mapping.FolderNamespace.Length + 1) // include the last dot }); } }
/// <summary> /// Create mappings for all resources in a specific namespace (and all sub namespaces). /// </summary> /// <param name="mapping">Mapping to load embedded resources in</param> protected void Map(NamespaceMapping mapping) { if (mapping == null) throw new ArgumentNullException("mapping"); var names = mapping.Assembly.GetManifestResourceNames(); foreach (var name in names) { if (!name.StartsWith(mapping.FolderNamespace)) continue; if (!IsFileAllowed(name)) continue; _resourceNames.Add(new MappedResource { Assembly = mapping.Assembly, AssemblyDate = new FileInfo(mapping.Assembly.Location).CreationTimeUtc, FullResourceName = name, ResourceRoot = mapping.FolderNamespace, ResourceName = name.Remove(0, mapping.FolderNamespace.Length + 1) // include the last dot }); } }