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


C# Utils.LogError方法代码示例

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


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

示例1: Create


//.........这里部分代码省略.........
                                _scriptFactory.ScriptUri = autoConfigUri;
                                _scriptFactory.Script = scriptData;
                            }
                        }

                        ret = _scriptFactory.Create(logger);
                    }
                    else
                    {
                        string proxyServer = settings.GetValue("ProxyServer") as string;

                        if (proxyServer != null)
                        {
                            string[] servers = proxyServer.ToLower().Split(new[] { ' ', ';' }, StringSplitOptions.RemoveEmptyEntries);
                            string currServer = null;
                            bool socks = false;

                            // Take socks in preference, otherwise accept HTTP or default
                            foreach (string server in servers)
                            {
                                if (server.Contains('='))
                                {
                                    if (server.StartsWith("socks="))
                                    {
                                        currServer = server.Substring(6).Trim();
                                        logger.LogVerbose("Found system SOCKS server {0}", currServer);
                                        socks = true;
                                        break;
                                    }
                                    else if (server.StartsWith("http="))
                                    {
                                        currServer = server.Substring(5).Trim();
                                        logger.LogVerbose("Found system HTTP proxy {0}", currServer);
                                    }
                                }
                                else
                                {
                                    currServer = server.Trim();
                                    logger.LogVerbose("Found default HTTP proxy {0}", currServer);
                                }
                            }

                            if (currServer != null)
                            {
                                string host = null;
                                int port = 0;

                                if (currServer.Contains("/"))
                                {
                                    if (Uri.IsWellFormedUriString(currServer, UriKind.Absolute))
                                    {
                                        Uri uri = new Uri(currServer);

                                        host = uri.Host;
                                        port = uri.Port;
                                    }
                                }
                                else
                                {
                                    string[] values = currServer.Split(':');
                                    if (values.Length == 2)
                                    {
                                        host = values[0].Trim();
                                        int.TryParse(values[1].Trim(), out port);
                                    }
                                }

                                if (String.IsNullOrWhiteSpace(host) || (port <= 0) || (port > 65535))
                                {
                                    logger.LogError("Invalid system proxy string {0}", currServer);
                                }
                                else
                                {
                                    if (socks)
                                    {
                                        ret = new SocksProxyClient(host, port, false, SocksProxyClient.SupportedVersion.Version4, false);
                                    }
                                    else
                                    {
                                        ret = new HttpProxyClient(host, port, false);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (SecurityException)
            {
            }
            catch (UnauthorizedAccessException)
            {
            }
            catch (WebException ex)
            {
                logger.LogException(ex);
            }

            return ret;
        }
开发者ID:michyer,项目名称:canape,代码行数:101,代码来源:SystemProxyClientFactory.cs

示例2: Create

        /// <summary>
        /// Create client
        /// </summary>
        /// <param name="logger">The logger to use</param>
        /// <returns>The new proxy client</returns>
        public override ProxyClient Create(Utils.Logger logger)
        {
            IWebProxyScript proxyScript = GetProxyInstance();

            if (proxyScript == null)
            {
                logger.LogError(Properties.Resources.ScriptProxyFactory_CannotCreateScript);
                return new IpProxyClient();
            }
            else
            {
                return new ScriptProxyClient(proxyScript);
            }
        }
开发者ID:michyer,项目名称:canape,代码行数:19,代码来源:ScriptProxyClientFactory.cs


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