コード例 #1
0
        public void LoadConfig_ConfigFileFound_LoadsConfiguration()
        {
            const string configFileContents = @"
                    { 
                        ""PackageType"" : ""NuGet"", 
                        ""PackageSource"" : ""d:\\test"" ,
                        ""InstallRoot"" : ""Apps""
                    }";

            _fs.Setup(x => x.File.Exists("config.json")).Returns(true);
            _fs.Setup(x => x.File.ReadAllText("config.json")).Returns(configFileContents);

            var configuration = _cfgManager.LoadConfig();

            Assert.That(configuration.PackageType, Is.EqualTo(PackageType.NuGet));
            Assert.That(configuration.PackageSource, Is.EqualTo("d:\\test"));
            Assert.That(configuration.InstallRoot, Is.EqualTo("Apps"));
        }
コード例 #2
0
        public void Execute()
        {
            string settingAndValue = _config.SetConfigurationValue;

            string[] split = settingAndValue.Split('=');

            var deploydConfiguration = _configurationManager.LoadConfig();

            if (split.Length == 1 || split.Length == 2)
            {
                var property = typeof(DeploydConfiguration).GetProperty(split[0]);

                if (property != null)
                {
                    if (split.Length == 2)
                    {
                        if (property.PropertyType.IsEnum)
                        {
                            property.SetValue(deploydConfiguration, Enum.Parse(property.PropertyType, split[1], true), null);
                        }
                        else
                        {
                            property.SetValue(deploydConfiguration, Convert.ChangeType(split[1], property.PropertyType), null);
                        }
                        _configurationManager.SaveConfig(deploydConfiguration);
                    }
                    else
                    {
                        _output.WriteLine("{0}={1}", split[0], property.GetValue(deploydConfiguration, null));
                    }
                    return;
                }
                _output.WriteLine("No such configuration option '{0}'", split[0]);
                return;
            }

            throw new ArgumentException("Usage: deployd --set [option]=[value]");
        }
コード例 #3
0
 public DeploydConfiguration LoadConfiguration()
 {
     return(_cfgManager.LoadConfig());
 }