コード例 #1
0
        public static ConfigOptions GetConfigOptions(string[] args)
        {
            var config = new ConfigOptions();

            if (args.Length == 0)
            {
                return(config);
            }
            for (var i = 0; i < args.Length; i++)
            {
                switch (args[i].ToLower())
                {
                case "-file":
                case "-f":
                    config.ImportFile      = args[i + 1];
                    config.ImportDirectory = "none";
                    break;

                case "-directory":
                case "-d":
                    config.ImportDirectory = args[i + 1];
                    break;

                case "-backup":
                case "-b":
                    config.BackupConfiguration = true;
                    config.ImportDirectory     = "none";
                    break;

                case "-xml":
                case "-x":
                    config.XmlValidation = args[i + 1];
                    break;

                case "-list":
                case "-l":
                    config.ListInstalledPalettes = true;
                    config.ImportDirectory       = "none";
                    break;

                case "-?":
                case "-help":
                    PrintHelp();
                    config.ImportDirectory = "none";
                    break;
                }
            }
            return(config);
        }
コード例 #2
0
        public ColorPalette(ConfigOptions config)
        {
            var configFolder = config.ConfigurationFolder;

            _configFile = Path.Combine(configFolder, FileName);
            _localPath  = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
            SchemaSet   = SetXmlSchema(config.XmlValidation);

            Xdoc    = XDocument.Load(_configFile);
            Vanilla = Xdoc.Descendants().First(key => (string)key.Attribute("name") == ".Vanilla");
            Build   = Vanilla.AttributeOrEmpty("build").Value;

            if (config.BackupConfiguration)
            {
                BackupConfiguration(configFolder, _configFile);
            }

            ColorCount = Vanilla.Descendants().Count(key => (string)key.Attribute("name") == "Colors");

            InstalledThemes = ColorCount == 0 ? new List <string>() : GetInstalledPalettes();
        }