本文整理汇总了C#中IServerConfig.CopyPropertiesTo方法的典型用法代码示例。如果您正苦于以下问题:C# IServerConfig.CopyPropertiesTo方法的具体用法?C# IServerConfig.CopyPropertiesTo怎么用?C# IServerConfig.CopyPropertiesTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IServerConfig
的用法示例。
在下文中一共展示了IServerConfig.CopyPropertiesTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResolveServerConfig
private IServerConfig ResolveServerConfig(IServerConfig serverConfig)
{
var config = new ServerConfig();
serverConfig.CopyPropertiesTo(config);
if (serverConfig.Port > 0)
{
var endPointKey = serverConfig.Name + "_" + serverConfig.Port;
var instanceEndpoint = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints[endPointKey];
if (instanceEndpoint == null)
{
Trace.WriteLine(string.Format("Failed to find Input Endpoint configuration {0}!", endPointKey), "Error");
return serverConfig;
}
var ipEndpoint = instanceEndpoint.IPEndpoint;
config.Ip = ipEndpoint.Address.ToString();
config.Port = ipEndpoint.Port;
}
if (config.Listeners != null && config.Listeners.Any())
{
var listeners = config.Listeners.ToArray();
var newListeners = new List<ListenerConfig>(listeners.Length);
for (var i = 0; i < listeners.Length; i++)
{
var listener = listeners[i];
var endPointKey = serverConfig.Name + "_" + listener.Port;
var instanceEndpoint = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints[endPointKey];
if (instanceEndpoint == null)
{
Trace.WriteLine(string.Format("Failed to find Input Endpoint configuration {0}!", endPointKey), "Error");
return serverConfig;
}
var newListener = new ListenerConfig();
newListener.Ip = instanceEndpoint.IPEndpoint.Address.ToString();
newListener.Port = instanceEndpoint.IPEndpoint.Port;
newListener.Backlog = listener.Backlog;
newListeners.Add(newListener);
}
config.Listeners = newListeners;
}
return config;
}
示例2: ResolveServerConfig
private IServerConfig ResolveServerConfig(IServerConfig serverConfig)
{
var config = new ServerConfig();
serverConfig.CopyPropertiesTo(config);
var instanceEndpoint = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints[serverConfig.Name + "Endpoint"];
if (instanceEndpoint == null)
{
Trace.WriteLine(string.Format("Failed to find Input Endpoint configuration {0}!", serverConfig.Name + "Endpoint"), "Error");
return serverConfig;
}
var ipEndpoint = instanceEndpoint.IPEndpoint;
config.Ip = ipEndpoint.Address.ToString();
config.Port = ipEndpoint.Port;
return config;
}
示例3: ResolveServerConfig
private IServerConfig ResolveServerConfig(IServerConfig serverConfig)
{
var config = new ServerConfig();
serverConfig.CopyPropertiesTo(config);
RoleInstanceEndpoint instanceEndpoint;
if (!RoleEnvironment.CurrentRoleInstance.InstanceEndpoints.TryGetValue(serverConfig.Name + "Endpoint", out instanceEndpoint))
{
Trace.WriteLine(string.Format("Failed to find Input Endpoint configuration {0}!", serverConfig.Name + "Endpoint"), "Error");
return serverConfig;
}
var ipEndpoint = instanceEndpoint.IPEndpoint;
config.Ip = ipEndpoint.Address.ToString();
config.Port = ipEndpoint.Port;
List<int> dataPorts = new List<int>();
int dataPortIndex = 0;
while (true)
{
var dataPortKey = "FTPDataPort" + dataPortIndex++;
RoleInstanceEndpoint dataEndpoint;
if (!RoleEnvironment.CurrentRoleInstance.InstanceEndpoints.TryGetValue(dataPortKey, out dataEndpoint))
break;
dataPorts.Add(dataEndpoint.IPEndpoint.Port);
}
if (dataPorts.Count > 0)
config.Options["dataPort"] = string.Join(",", dataPorts.Select(p => p.ToString()).ToArray());
return config;
}