本文整理汇总了C#中Configuration.Get方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.Get方法的具体用法?C# Configuration.Get怎么用?C# Configuration.Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Configuration
的用法示例。
在下文中一共展示了Configuration.Get方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HttpAddressingScheme
public HttpAddressingScheme(INetworkEnvironment network) {
Network = network;
Name = Network.LocalIPAddress.ToString();
var cfg = new Configuration().WithAppropriateOverrides();
UseSsl = cfg.Get(Constants.Configuration.EncryptedTransportRequired);
Port = cfg.Get(UseSsl ? Constants.Configuration.ExternalSecureEventListenerPort : Constants.Configuration.ExternalEventListenerPort).ToString();
}
示例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: ListOne
public static void ListOne(Configuration cfg, string name)
{
var alias= cfg.Get<string>(String.Concat(prefix, name));
if (alias == null)
Console.Error.WriteLine("No such alias '{0}'", name);
else
Console.WriteLine("{0} = {1}", name, alias.Value);
}
示例4: CanGetGlobalStringValueWithoutRepo
public void CanGetGlobalStringValueWithoutRepo()
{
using (var config = new Configuration())
{
InconclusiveIf(() => !config.HasGlobalConfig, "No Git global configuration available");
config.Get<string>("user.name", null).ShouldNotBeNull();
}
}
示例5: Fabricate
public static Neighbour Fabricate(IStateMachineContext<IExecutionContext> context) {
var cfg = new Configuration().WithAppropriateOverrides();
var nexus = cfg.Get(Constants.Configuration.Nexus);
var strength = cfg.Get(Constants.Configuration.MachineStrength);
var actualStrength = string.IsNullOrEmpty(strength) ? MachineStrength.Compute : (MachineStrength)Enum.Parse(typeof(MachineStrength), strength, true);
return new Neighbour {
IsMaster = context.ExecutionContext.IsMaster,
Name = context.ExecutionContext.HostName,
UpTime = context.EnclosingMachine.UpTime,
AbsoluteBootTime = context.EnclosingMachine.AbsoluteBootTime,
Strength = actualStrength.ToString(),
// Could be null if not yet interrogated
Hardware = HardwareDetails.Instance ?? new HardwareDetails(),
InEligibleForElection = context.ExecutionContext.InEligibleForElection,
PendingEvents = context.EnclosingMachine.PendingEvents.Select(e => new PendingEvent { Id = e.Id, Name = e.EventName, CreatedOn = e.CreatedOn, AgeInSeconds = (DateTime.Now - e.CreatedOn).TotalSeconds }).ToArray(),
HandledEvents = context.EnclosingMachine.StatisticsHandler.HandledEventsInNameOrder.ToArray(),
WorkUnitsExecuted = context.ExecutionContext.WorkerExecutionUnits,
NodeId = context.ExecutionContext.NodeId,
SupposedNeighbours = string.IsNullOrEmpty(nexus) ? Enumerable.Empty<string>().ToArray() : nexus.Split(','),
CurrentState = context.EnclosingMachine.CurrentState.IsNull() ? "None" : context.EnclosingMachine.CurrentState.Name
};
}
示例6: Load
public static void Load(string[] args)
{
_conf = new Configuration();
_conf.ReadFile("../../conf/login.conf");
if (args != null)
_conf.ReadArguments(args, "../../");
LoginConf.ConsoleFilter = (LogLevel)_conf.GetInt("login.consolefilter", 0);
#if DEBUG
// Enable debug regardless of configuration in debug builds.
LoginConf.ConsoleFilter &= ~LogLevel.Debug;
#endif
LoginConf.Password = _conf.GetString("inter.password", "aura");
LoginConf.DataPath = _conf.GetString("data.path", "../../data");
LoginConf.Localization = _conf.GetString("data.localization", "us");
LoginConf.DatabaseHost = _conf.GetString("database.host", "localhost");
LoginConf.DatabaseUser = _conf.GetString("database.user", "root");
LoginConf.DatabasePass = _conf.GetString("database.pass", "");
LoginConf.DatabaseDb = _conf.GetString("database.db", "aura");
LoginConf.Port = _conf.Get<ushort>("login.port", 11000);
LoginConf.ConsumeCards = _conf.GetBool("login.consumecards", true);
LoginConf.NewAccounts = _conf.GetBool("login.newaccounts", true);
LoginConf.DeletionWait = _conf.Get<int>("login.deletewait", 107);
if (LoginConf.DeletionWait < 0 || (LoginConf.DeletionWait > 23 && LoginConf.DeletionWait < 100) || LoginConf.DeletionWait > 123)
{
Logger.Warning("Invalid format for 'login.deletewait', setting to 0.");
LoginConf.DeletionWait = 0;
}
LoginConf.EnableSecondaryPassword = _conf.GetBool("login.enable_sec", true);
}
示例7: BrokerApiTests
public BrokerApiTests()
{
var configuration = new Configuration();
this.documentClient = new DocumentClient(new Uri(configuration.Get<string>("AccountEndpoint")), configuration.Get<string>("AccountKey"));
}
示例8: CanGetGlobalStringValueWithoutRepo
public void CanGetGlobalStringValueWithoutRepo()
{
using (var config = new Configuration())
{
InconclusiveIf(() => !config.HasConfig(ConfigurationLevel.Global),
"No Git global configuration available");
Assert.NotNull(config.Get<string>("user.name"));
}
}
示例9: 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);
}
}
}
示例10: Load
public static void Load(string[] args)
{
_conf = new Configuration();
_conf.ReadFile("../../conf/world.conf");
if (args != null)
_conf.ReadArguments(args, "../../");
WorldConf.ConsoleFilter = (LogLevel)_conf.GetInt("world.consolefilter", 0);
#if DEBUG
// Enable debug regardless of configuration in debug builds.
WorldConf.ConsoleFilter &= ~LogLevel.Debug;
#endif
WorldConf.Password = _conf.GetString("inter.password", "aura");
WorldConf.DataPath = _conf.GetString("data.path", "../../data");
WorldConf.Localization = _conf.GetString("data.localization", "us");
WorldConf.DatabaseHost = _conf.GetString("database.host", "localhost");
WorldConf.DatabaseUser = _conf.GetString("database.user", "root");
WorldConf.DatabasePass = _conf.GetString("database.pass", "");
WorldConf.DatabaseDb = _conf.GetString("database.db", "aura");
WorldConf.ServerName = _conf.GetString("world.servername", "Dummy");
WorldConf.ChannelName = _conf.GetString("world.channelname", "Ch1");
WorldConf.ChannelHost = _conf.GetString("world.channelhost", "127.0.0.1");
WorldConf.ChannelPort = (ushort)_conf.GetInt("world.channelport", 11020);
WorldConf.CachePath = _conf.GetString("world.cache", "../../cache");
WorldConf.LoginHost = _conf.GetString("world.loginhost", "127.0.0.1");
WorldConf.LoginPort = (ushort)_conf.GetInt("world.loginport", 11000);
WorldConf.CommandPrefix = _conf.GetString("commands.prefix", ">")[0];
WorldConf.ScriptPath = _conf.GetString("script.path", "../../scripts");
WorldConf.DisableScriptCaching = _conf.GetBool("script.disable_cache", false);
WorldConf.ScriptStrictMode = _conf.GetBool("script.strict_mode", false);
WorldConf.SightRange = _conf.Get<uint>("world.sightrange", 3000);
WorldConf.AutoSendGMCP = _conf.GetBool("world.auto_gmcp", false);
WorldConf.MinimumGMCP = _conf.Get<byte>("world.minimum_gmcp", 50);
WorldConf.MinimumGMCPSummon = _conf.Get<byte>("world.minimum_gmcp_summon", 50);
WorldConf.MinimumGMCPCharWarp = _conf.Get<byte>("world.minimum_gmcp_char_warp", 50);
WorldConf.MinimumGMCPMove = _conf.Get<byte>("world.minimum_gmcp_move", 50);
WorldConf.MinimumGMCPRevive = _conf.Get<byte>("world.minimum_gmcp_revive", 50);
WorldConf.MinimumGMCPInvisible = _conf.Get<byte>("world.minimum_gmcp_invisible", 50);
WorldConf.MinimumGMCPExpel = _conf.Get<byte>("world.minimum_gmcp_expel", 50);
WorldConf.MinimumGMCPBan = _conf.Get<byte>("world.minimum_gmcp_ban", 50);
WorldConf.ExpRate = _conf.Get<float>("world.exp_rate", 100f) / 100.0f;
WorldConf.DropRate = _conf.Get<float>("world.drop_rate", 100f) / 100.0f;
WorldConf.GoldDropRate = _conf.Get<float>("world.gold_drop_rate", 30f) / 100.0f;
WorldConf.PropDropRate = _conf.Get<float>("world.prop_drop_rate", 30f) / 100.0f;
WorldConf.EnableItemShop = _conf.GetBool("world.enable_itemshop", false);
WorldConf.MailExpires = _conf.GetInt("world.mail_expires", 30);
WorldConf.EnableVisual = _conf.GetBool("world.enable_visual", true);
WorldConf.SafeDye = _conf.GetBool("world.safe_dye", false);
WorldConf.BunshinSouls = _conf.GetBool("world.bunshinsouls", true);
WorldConf.PerfectPlay = _conf.GetBool("world.perfectplay", false);
WorldConf.DkSoundFix = _conf.GetBool("world.dk_sound_fix", true);
WorldConf.ColorChange = _conf.GetBool("world.colorchange", true);
WorldConf.DynamicCombat = _conf.GetBool("world.dynamic_combat", true);
WorldConf.TimeBeforeAncient = _conf.GetInt("world.time_before_ancient", 300);
WorldConf.AncientRate = _conf.Get<float>("world.ancient_rate", .33f);
WorldConf.NpcIntroOnce = _conf.GetBool("world.npc_intro_once", true);
try
{
WorldConf.Motd = File.ReadAllText("../../conf/motd.txt");
}
catch (FileNotFoundException)
{
Logger.Warning("'motd.txt' not found.");
WorldConf.Motd = string.Empty;
}
}
示例11: Init
/// <summary>
/// Private. Init library
/// </summary>
/// <param name="configuration"></param>
private static void Init(Configuration configuration)
{
lock (_lock)
{
if (_instance != null)
{
throw new InvalidOperationException("CMClient already initialized");
}
_instance = new CMClient();
_instance.ServerUrl = configuration.Get<String>(CmRgServerUrl);
_instance.ApiKey = configuration.Get<String>(CmCustomerKey);
_instance.UserId = configuration.Get<String>(CmUserId);
_instance.Email = configuration.Get<String>(CmEmail);
_instance.Locale = configuration.Get<String>(CmLocale);
_instance.UseGps = configuration.Get<Boolean>(CmUseGpsLocation);
_dispatcher = SynchronizationContext.Current;
_instance.GetPushedMessages(new CMClientListenerImpl());
}
}
示例12: ShouldThrowAnExceptionWhenAConfigurationIsMissing
public void ShouldThrowAnExceptionWhenAConfigurationIsMissing()
{
var infrastructure = new Configuration("infrastructure");
var connections = new Configuration("connections", c => c.BelongingTo(infrastructure));
try
{
connections.Get("database");
}
catch (Exception e)
{
Assert.AreEqual(
"The configuration named [database] was requested, " +
"but could not be located, on the base configuration [infrastructure.connections]. " +
"Are you missing a key on your configuration file(s)?",
e.Message);
throw;
}
}
示例13: ShouldBeAbleToGetAValidConfiguration
public void ShouldBeAbleToGetAValidConfiguration()
{
var connections = new Configuration("connections");
var database = new Configuration("database", "localhost", c => c.BelongingTo(connections));
Assert.AreSame(database, connections.Get("database"));
}
示例14: NameShouldNotBeCaseSensitive
public void NameShouldNotBeCaseSensitive()
{
var connections = new Configuration("connections");
var database = new Configuration("database", "localhost", c => c.BelongingTo(connections));
Assert.AreEqual(database, connections.Get("DaTabase"));
}