Beispiel #1
0
        public static ThemeInfo Parse(string path)
        {
            var theme = new ThemeInfo();

            if (path == null || !File.Exists(path))
            {
                theme.IsValid = false;
            }

            theme.ThemeName = Get(path, "ThemeName");
            theme.Author = Get(path, "Author");
            theme.AuthorEmail = Get(path, "AuthorEmail");
            theme.ConvertedBy = Get(path, "ConvertedBy");
            theme.ReleasedOn = Get(path, "ReleasedOn");
            theme.Version = Get(path, "Version");
            theme.Category = Get(path, "Category");
            theme.Responsive = Get(path, "Responsive").ToUpperInvariant().Equals("TRUE");
            theme.Framework = Get(path, "Framework");
            theme.Tags = Get(path, "Tags").Split(',');
            theme.HomepageLayout = Get(path, "HomepageLayout");
            theme.DefaultLayout = Get(path, "DefaultLayout");

            string directory = Path.GetDirectoryName(path);

            if (directory == null || string.IsNullOrWhiteSpace(theme.ThemeName))
            {
                theme.IsValid = false;
                return theme;
            }

            if (!File.Exists(Path.Combine(directory, theme.HomepageLayout)))
            {
                throw new ThemeInfoException(
                    "The homepage layout path of this theme as per the configuration file does not exist or is invalid.");
            }

            if (!File.Exists(Path.Combine(directory, theme.DefaultLayout)))
            {
                throw new ThemeInfoException(
                    "The default layout path of this theme as per the configuration file does not exist or is invalid.");
            }

            theme.IsValid = true;

            return theme;
        }
Beispiel #2
0
        public static ThemeInfo Parse(string path)
        {
            var theme = new ThemeInfo();

            if (path == null || !File.Exists(path))
            {
                theme.IsValid = false;
            }

            theme.ThemeName      = Get(path, "ThemeName");
            theme.Author         = Get(path, "Author");
            theme.AuthorEmail    = Get(path, "AuthorEmail");
            theme.ConvertedBy    = Get(path, "ConvertedBy");
            theme.ReleasedOn     = Get(path, "ReleasedOn");
            theme.Version        = Get(path, "Version");
            theme.Category       = Get(path, "Category");
            theme.Responsive     = Get(path, "Responsive").ToUpperInvariant().Equals("TRUE");
            theme.Framework      = Get(path, "Framework");
            theme.Tags           = Get(path, "Tags").Split(',');
            theme.HomepageLayout = Get(path, "HomepageLayout");
            theme.DefaultLayout  = Get(path, "DefaultLayout");

            string directory = Path.GetDirectoryName(path);

            if (directory == null || string.IsNullOrWhiteSpace(theme.ThemeName))
            {
                theme.IsValid = false;
                return(theme);
            }

            if (!File.Exists(Path.Combine(directory, theme.HomepageLayout)))
            {
                throw new ThemeInfoException(
                          "The homepage layout path of this theme as per the configuration file does not exist or is invalid.");
            }

            if (!File.Exists(Path.Combine(directory, theme.DefaultLayout)))
            {
                throw new ThemeInfoException(
                          "The default layout path of this theme as per the configuration file does not exist or is invalid.");
            }

            theme.IsValid = true;

            return(theme);
        }
Beispiel #3
0
        private bool Validate()
        {
            string configFile = Path.Combine(this.ExtractedDirectory, "Theme.config");

            if (!File.Exists(configFile))
            {
                return false;
            }

            var info = ThemeInfoParser.Parse(configFile);

            if (info == null || !info.IsValid)
            {
                return false;
            }

            this.ThemeInfo = info;
            return true;
        }
Beispiel #4
0
 public ThemeCreator(ThemeInfo info)
 {
     this.Info = info;
 }