Beispiel #1
0
        public string GetResource(string filename)
        {
            filename = filename.ToLowerInvariant();
            string result = _manifestResourceStreamService.GetManifestResourceText(GetType(), ResourcesPath + "." + filename, () => "");

            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// extracts the resource out of the binary
        /// </summary>
        /// <param name="filename"></param>
        /// <returns></returns>
        public string GetResource(string filename)
        {
            filename = filename.ToLowerInvariant();
            string result;

            if (_resourceCache.TryGetValue(filename, out result))
            {
                return(result);
            }

            result = _manifestResourceStreamService.GetManifestResourceText(GetType(), _registration.GetScsRegistration(GetType()).ResourcesPath + "." + filename, () => throw new ScsEmbeddedResourceNotFoundException());

            _resourceCache[filename] = result;
            return(result);
        }
        /// <summary>
        /// extracts the resource out of the binary
        /// </summary>
        /// <param name="filename"></param>
        /// <returns></returns>
        public string GetResource(string filename)
        {
            filename = filename.ToLowerInvariant();
            Sitecore.Context.SetActiveSite("scs");
            _resourceCache.TryGetValue(GetType(), out var cache);
            if (cache != null && cache.TryGetValue(filename, out var result))
            {
                return(result);
            }

            result = _manifestResourceStreamService.GetManifestResourceText(GetType(), _registration.GetScsRegistration(GetType()).ResourcesPath + "." + filename, () => throw new ScsEmbeddedResourceNotFoundException());
            if (!_resourceCache.ContainsKey(GetType()))
            {
                _resourceCache[GetType()] = new ConcurrentDictionary <string, string>();
            }
            _resourceCache[GetType()][filename] = result;
            return(result);
        }