Esempio n. 1
0
        /// <summary>
        /// Finds content int zippped file
        /// </summary>
        /// <param name="contentSource">Content source</param>
        /// <param name="resourcePath">Resource path</param>
        /// <param name="throwException">Sets wether throw exception or not</param>
        /// <returns>Returns resource paths found</returns>
        /// <remarks>
        /// Content source can be a folder or a zip file
        /// If not unique file found, searchs pattern "[filename]*[extension]" and returns result array
        /// </remarks>
        private static IEnumerable <MemoryStream> FindContentZip(string contentSource, string resourcePath, bool throwException)
        {
            if (ZipManager.Contains(contentSource, resourcePath))
            {
                return(new[] { ZipManager.GetFile(contentSource, resourcePath) });
            }

            var res = ZipManager.GetFiles(contentSource, Path.GetFileNameWithoutExtension(resourcePath) + "*" + Path.GetExtension(resourcePath));

            if (res?.Any() == true)
            {
                return(res.ToArray());
            }

            if (throwException)
            {
                throw new FileNotFoundException("File not found", resourcePath);
            }

            return(new MemoryStream[] { });
        }