Ejemplo n.º 1
0
        public virtual void SaveImage(Site site, string themeName, string fileName, Stream stream)
        {
            Theme          theme = new Theme(site, themeName);
            ThemeImageFile image = new ThemeImageFile(theme, fileName);

            image.Save(stream);
        }
Ejemplo n.º 2
0
        public virtual void DeleteImage(Site site, string themeName, string fileName)
        {
            Theme          theme = new Theme(site, themeName);
            ThemeImageFile image = new ThemeImageFile(theme, fileName);

            if (!image.Exists())
            {
                throw new FriendlyException("image:" + fileName + " does not exist!");
            }
            image.Delete();
        }
Ejemplo n.º 3
0
        public void TestVirtualPath()
        {
            string themeName      = "theme1";
            var    site           = new Site("Site1");
            var    theme          = new Theme(site, themeName);
            var    themeImageFile = new ThemeImageFile(theme, "image1.jpg");

            string expected1 = Kooboo.Web.Url.UrlUtility.Combine(site.VirtualPath, "themes", themeName, "Images", "image1.jpg");

            Assert.AreEqual(expected1, themeImageFile.VirtualPath, true);
        }
Ejemplo n.º 4
0
        public void TestPhysicalPath()
        {
            string themeName      = "theme1";
            var    site           = new Site("Site1");
            var    theme          = new Theme(site, themeName);
            var    themeImageFile = new ThemeImageFile(theme, "image1.jpg");

            string expected1 = Path.Combine(site.PhysicalPath, "themes", themeName, "Images", "image1.jpg");

            Assert.AreEqual(expected1, themeImageFile.PhysicalPath, true);
        }
Ejemplo n.º 5
0
        public IEnumerable <ThemeImageFile> AllImagesEnumerable(Theme theme)
        {
            List <ThemeImageFile> list = new List <ThemeImageFile>();

            theme = theme.LastVersion();
            if (theme.Exists())
            {
                ThemeImageFile dummy   = new ThemeImageFile(theme, "dummy");
                var            baseDir = dummy.BasePhysicalPath;
                if (Directory.Exists(baseDir))
                {
                    foreach (var file in Directory.EnumerateFiles(baseDir))
                    {
                        list.Add(new ThemeImageFile(theme, Path.GetFileName(file)));
                    }
                }
            }
            return(list);
        }