示例#1
0
        static void SaveConfig(TeamFlashConfig config)
        {
            var appDataPath   = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            var teamFlashPath = Path.Combine(appDataPath, @"TeamFlash\");

            if (!Directory.Exists(teamFlashPath))
            {
                Directory.CreateDirectory(teamFlashPath);
            }

            var configFilePath = Path.Combine(teamFlashPath, @"config.json");

            var serializer = new XmlSerializer(typeof(TeamFlashConfig));

            using (var stream = File.Create(configFilePath))
            {
                serializer.Serialize(stream, config);
            }
        }
示例#2
0
        private static IBuildLight GetBuildLightDriver(TeamFlashConfig config)
        {
            IBuildLight driver = null;

            if (string.IsNullOrEmpty(config.BuildLightDriver) || config.BuildLightDriver == "*")
            {
                driver = DefaultBuildLight;
            }
            else
            {
                var type = Type.GetType(config.BuildLightDriver);
                if (type == null)
                {
                    return(DefaultBuildLight);
                }
                driver = type.Assembly.CreateInstance(config.BuildLightDriver, true) as IBuildLight;
            }
            if (driver == null)
            {
                driver = DefaultBuildLight;
            }
            return(driver);
        }
示例#3
0
        static void SaveConfig(TeamFlashConfig config)
        {
            var appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            var teamFlashPath = Path.Combine(appDataPath, @"TeamFlash\");
            if (!Directory.Exists(teamFlashPath))
                Directory.CreateDirectory(teamFlashPath);

            var configFilePath = Path.Combine(teamFlashPath, @"config.json");

            var serializer = new XmlSerializer(typeof(TeamFlashConfig));
            using (var stream = File.OpenWrite(configFilePath))
            {
                serializer.Serialize(stream, config);
            }
        }