コード例 #1
0
        public void AddFiles(Dictionary <string, IFileInfo> files)
        {
            var lastModificationTime = GetLastModificationTime();

            foreach (var resourcePath in Assembly.GetManifestResourceNames())
            {
                if (!BaseNamespace.IsNullOrEmpty() && !resourcePath.StartsWith(BaseNamespace))
                {
                    continue;
                }

                var fullPath = ConvertToRelativePath(resourcePath).EnsureStartsWith('/');

                if (fullPath.Contains("/"))
                {
                    AddDirectoriesRecursively(files, fullPath.Substring(0, fullPath.LastIndexOf('/')), lastModificationTime);
                }

                files[fullPath] = new EmbeddedResourceFileInfo(
                    Assembly,
                    resourcePath,
                    fullPath,
                    CalculateFileName(fullPath),
                    lastModificationTime
                    );
            }
        }
コード例 #2
0
        private string ConvertToRelativePath(string resourceName)
        {
            if (!BaseNamespace.IsNullOrEmpty())
            {
                resourceName = resourceName.Substring(BaseNamespace.Length + 1);
            }

            var pathParts = resourceName.Split('.');

            if (pathParts.Length <= 2)
            {
                return(resourceName);
            }

            var folder   = pathParts.Take(pathParts.Length - 2).JoinAsString("/");
            var fileName = pathParts[pathParts.Length - 2] + "." + pathParts[pathParts.Length - 1];

            return(folder + "/" + fileName);
        }