本文整理汇总了C#中Configuration.Set方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.Set方法的具体用法?C# Configuration.Set怎么用?C# Configuration.Set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Configuration
的用法示例。
在下文中一共展示了Configuration.Set方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConfigureGitConfig
public static void ConfigureGitConfig(
ConfigurationLevel level = ConfigurationLevel.Global,
string file = null )
{
var config = new Configuration( file, file, file );
LogManager.GetCurrentClassLogger().Info( "Installing failmerge driver to " + ( file ?? level.ToString() ) );
config.Set( "merge.failmerge.name", "fail merge driver", level );
config.Set( "merge.failmerge.driver", "false", level );
config.Set( "merge.failmerge.recursive", "binary", level );
}
示例2: GetChromeDriverDir
public static string GetChromeDriverDir(Configuration cfg)
{
string chromeDriverDir = cfg.Get("PiroPiro.Selenium.ChromeDriverDir", false);
if (string.IsNullOrEmpty(chromeDriverDir))
{
#region FindChromeDriverExe
chromeDriverDir = Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(typeof(SeleniumBrowserFactory)).Location);
while (!File.Exists(Path.Combine(chromeDriverDir, "chromedriver.exe")))
{
if (chromeDriverDir == "" || chromeDriverDir == Path.GetPathRoot(chromeDriverDir))
{
chromeDriverDir = null;
break;
}
chromeDriverDir = Path.GetDirectoryName(chromeDriverDir);
}
#endregion
if (!string.IsNullOrEmpty(chromeDriverDir))
{
cfg.Set("PiroPiro.Selenium.ChromeDriverDir", chromeDriverDir);
}
else
{
chromeDriverDir = Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(typeof(SeleniumBrowserFactory)).Location);
throw new Exception("chromediver.exe not found in \"" + chromeDriverDir + "\", use ChromeDriverDir setting to specify a path");
}
}
return chromeDriverDir;
}
示例3: Set
public static void Set(Configuration allcfg, string name, string value)
{
allcfg.Set<string>(String.Concat(prefix, name), value, ConfigurationLevel.Global);
}
示例4: SettingLocalConfigurationOutsideAReposThrows
public void SettingLocalConfigurationOutsideAReposThrows()
{
using (var config = new Configuration())
{
Assert.Throws<LibGit2SharpException>(() => config.Set("unittests.intsetting", 3));
}
}
示例5: CanSetGlobalStringValueWithoutRepo
public void CanSetGlobalStringValueWithoutRepo()
{
using(var config = new Configuration())
{
InconclusiveIf(() => !config.HasConfig(ConfigurationLevel.Global),
"No Git global configuration available");
var existing = config.Get<string>("user.name");
Assert.NotNull(existing);
try
{
config.Set("user.name", "Unit Test", ConfigurationLevel.Global);
AssertValueInGlobalConfigFile("name = Unit Test$");
}
finally
{
config.Set("user.name", existing.Value, ConfigurationLevel.Global);
}
}
}
示例6: CreateConfigurationWithDummyUser
/// <summary>
/// Creates a configuration file with user.name and user.email set to signature
/// </summary>
/// <remarks>The configuration file will be removed automatically when the tests are finished</remarks>
/// <param name="signature">The signature to use for user.name and user.email</param>
/// <returns>The path to the configuration file</returns>
protected string CreateConfigurationWithDummyUser(Signature signature)
{
SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
Directory.CreateDirectory(scd.DirectoryPath);
string configFilePath = Path.Combine(scd.DirectoryPath, "global-config");
using (Configuration config = new Configuration(configFilePath))
{
config.Set("user.name", signature.Name, ConfigurationLevel.Global);
config.Set("user.email", signature.Email, ConfigurationLevel.Global);
}
return configFilePath;
}