public AssemblyResourcesContentSource(Assembly assembly, string rootPath = null)
        {
            RootPath   = rootPath;
            Rejections = new RejectedAssetCollection();

            var resourceNames = assembly.GetManifestResourceNames().ToList();

            if (RootPath != null)
            {
                PathRedirects = new Dictionary <string, string>();

                for (int i = 0; i < resourceNames.Count; i++)
                {
                    string path = resourceNames[i];

                    if (path.StartsWith(rootPath))
                    {
                        string shortPath = path.Substring(rootPath.Length);

                        resourceNames[i]         = shortPath;
                        PathRedirects[shortPath] = path;
                    }
                    else
                    {
                        resourceNames.RemoveAt(i--);
                    }
                }
            }

            ResourceNames = new HashSet <string>(resourceNames);

            this.assembly = assembly;
        }
Ejemplo n.º 2
0
        public AssemblyResourcesContentSource(Assembly assembly, string rootPath = null)
        {
            RootPath   = rootPath ?? "";
            Rejections = new RejectedAssetCollection();

            IEnumerable <string> resourceNames = assembly.GetManifestResourceNames();

            if (RootPath != null)
            {
                resourceNames = resourceNames
                                .Where(p => p.StartsWith(RootPath))
                                .Select(p => p.Substring(RootPath.Length));
            }

            ResourceNames = resourceNames.ToList();

            this.assembly = assembly;
        }