当前位置: 首页>>代码示例>>C#>>正文


C# IServerConfig.CopyPropertiesTo方法代码示例

本文整理汇总了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;
        }
开发者ID:iraychen,项目名称:SuperWebSocket,代码行数:51,代码来源:WorkerRole.cs

示例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;
        }
开发者ID:sandeeplocality,项目名称:UG12Server,代码行数:17,代码来源:WorkerRole.cs

示例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;
        }
开发者ID:jmptrader,项目名称:SuperSocket.FtpServer,代码行数:36,代码来源:WorkerRole.cs


注:本文中的IServerConfig.CopyPropertiesTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。