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


C# ServicePoint.GetType方法代码示例

本文整理汇总了C#中System.Net.ServicePoint.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# ServicePoint.GetType方法的具体用法?C# ServicePoint.GetType怎么用?C# ServicePoint.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Net.ServicePoint的用法示例。


在下文中一共展示了ServicePoint.GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PrintServicePointConnections

 private void PrintServicePointConnections(ServicePoint sp) {
     var spType = sp.GetType();
     var privateOrPublicInstanceField = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;
     var connectionGroupField = spType.GetField("m_ConnectionGroupList",privateOrPublicInstanceField);
     var value = (Hashtable)connectionGroupField.GetValue(sp);
     var connectionGroups = value.Keys.Cast<object>().ToList();
     var totalConnections = 0;
     Output("ServicePoint: {0} (Connection Limit: {1}, Reported connections: {2})", sp.Address,sp.ConnectionLimit,sp.CurrentConnections);
     foreach(var key in connectionGroups) {
         var connectionGroup = value[key];
         var groupType = connectionGroup.GetType();
         var listField = groupType.GetField("m_ConnectionList",privateOrPublicInstanceField);
         var listValue = (ArrayList)listField.GetValue(connectionGroup);
         //Console.WriteLine("{3} {0}\nConnectionGroup: {1} Count: {2}",sp.Address, key,listValue.Count, DateTime.Now);
         Output("{0}", key);
         totalConnections+=listValue.Count;
     }
     
     Output("ConnectionGroupCount: {0}, Total Connections: {1}", connectionGroups.Count, totalConnections);
 }
开发者ID:santosh-mnrec,项目名称:AzurePlot,代码行数:20,代码来源:ServicePointMonitor.cs

示例2: PrintServicePointConnections

        private ServicePointStatusServicePoint PrintServicePointConnections(ServicePoint sp)
        {
            var spType = sp.GetType();
            var privateOrPublicInstanceField = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;
            var connectionGroupField = spType.GetField("m_ConnectionGroupList", privateOrPublicInstanceField);
            var value = (Hashtable)connectionGroupField.GetValue(sp);
            var connectionGroups = value.Keys.Cast<object>().ToList();

            var servicePointStatus = new ServicePointStatusServicePoint
                                     {
                                         Address = sp.Address,
                                         ConnectionLimit = sp.ConnectionLimit,
                                         CurrentConnection = sp.CurrentConnections,
                                         ConnectionGroupCount = connectionGroups.Count,
                                         TotalConnections = 0
                                     };

            foreach (var key in connectionGroups)
            {
                var connectionGroup = value[key];
                var groupType = connectionGroup.GetType();
                var listField = groupType.GetField("m_ConnectionList", privateOrPublicInstanceField);
                var listValue = (ArrayList)listField.GetValue(connectionGroup);
                //Console.WriteLine("{3} {0}\nConnectionGroup: {1} Count: {2}",sp.Address, key,listValue.Count, DateTime.Now);

                servicePointStatus.ConnectionGroups.Add(new ServicePointStatusConnectionGroup
                                                        {
                                                            Key = key,
                                                            Count = listValue.Count
                                                        });

                servicePointStatus.TotalConnections += listValue.Count;
            }

            return servicePointStatus;
        }
开发者ID:srijken,项目名称:ServicePointManagerExtensions,代码行数:36,代码来源:ServicePointMonitor.cs


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