コード例 #1
0
ファイル: SpaModuleAssembly.cs プロジェクト: mtebenev/YesSpa
        /// <summary>
        /// ISpaModule
        /// This implementation accepts path in Orchard-like format:
        ///
        /// </summary>
        public IFileInfo GetFileInfo(string subpath)
        {
            if (!_fileInfos.TryGetValue(subpath, out var fileInfo))
            {
                lock (_fileInfos)
                {
                    if (!_fileInfos.TryGetValue(subpath, out fileInfo))
                    {
                        var resourcePath = _baseNamespace + subpath.Replace('/', '>');
                        var fileName     = Path.GetFileName(subpath);

                        if (_assembly.GetManifestResourceInfo(resourcePath) == null)
                        {
                            _logger.LogDebug(1, null, $"SpaModuleAssembly.GetFileInfo(): cannot find resource '{subpath}'");
                            fileInfo = new NotFoundFileInfo(fileName);
                        }
                        else
                        {
                            _logger.LogDebug(2, null, $"SpaModuleAssembly.GetFileInfo(): successfully loaded resource '{subpath}'");
                            _fileInfos[subpath] = fileInfo = new EmbeddedResourceFileInfo(_assembly.Object, resourcePath, fileName, _lastModified);
                        }
                    }
                }
            }

            return(fileInfo);
        }