本文整理汇总了C#中Akka.Configuration.Config.AsEnumerable方法的典型用法代码示例。如果您正苦于以下问题:C# Config.AsEnumerable方法的具体用法?C# Config.AsEnumerable怎么用?C# Config.AsEnumerable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Akka.Configuration.Config
的用法示例。
在下文中一共展示了Config.AsEnumerable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitServiceFromConfiguration
/// <summary>
/// Initializes nginx location configuration from self configuration
/// </summary>
/// <param name="host">The parent server configuration</param>
/// <param name="serviceName">Location name</param>
/// <param name="config">Section of self configuration, dedicated for the service configuration</param>
private void InitServiceFromConfiguration(HostConfiguration host, string serviceName, Config config)
{
StringBuilder serviceConfig = new StringBuilder();
foreach (var parameter in config.AsEnumerable())
{
if (parameter.Value.IsString())
{
serviceConfig.AppendFormat("\t\t{0} {1};\n", parameter.Key, parameter.Value.GetString());
}
else if (parameter.Value.IsArray())
{
var hoconValues = parameter.Value.GetArray();
foreach (var hoconValue in hoconValues)
{
serviceConfig.AppendFormat("\t\t{0} {1};\n", parameter.Key, hoconValue.GetString());
}
}
}
// proxy_set_header Host $http_host;
var headers = config.GetValue("proxy_set_header");
if (headers == null
|| (headers.IsString()
&& (headers.GetString() ?? string.Empty).ToLower()
.IndexOf("Host ", StringComparison.InvariantCulture) < 0)
|| (headers.IsArray()
&& headers.GetArray()
.Select(v => v.GetString())
.All(
v =>
(v ?? string.Empty).ToLower().IndexOf("Host ", StringComparison.InvariantCulture) < 0)))
{
serviceConfig.Append("\t\tproxy_set_header Host $http_host;\n");
}
host[serviceName].Config = serviceConfig.ToString();
}
示例2: InitHostFromConfiguration
/// <summary>
/// Initializes nginx server configuration from self configuration
/// </summary>
/// <param name="hostName">Local host identification</param>
/// <param name="config">Section of self configuration, dedicated for the host configuration</param>
private void InitHostFromConfiguration(string hostName, Config config)
{
StringBuilder hostConfig = new StringBuilder();
foreach (var parameter in config.AsEnumerable())
{
if (parameter.Value.IsString())
{
hostConfig.AppendFormat("\t{0} {1};\n", parameter.Key, parameter.Value.GetString());
}
if (parameter.Value.IsObject()
&& parameter.Key.StartsWith("location ", StringComparison.InvariantCultureIgnoreCase))
{
var serviceName = parameter.Key.Substring("location ".Length).Trim();
this.InitServiceFromConfiguration(
this.Configuration[hostName],
serviceName,
parameter.Value.AtKey("Key").GetConfig("Key"));
}
}
this.Configuration[hostName].Config = hostConfig.ToString();
}