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; }
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); }
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; }
public ThemeCreator(ThemeInfo info) { this.Info = info; }