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


C# StringReader.NonWhiteSpaceLines方法代码示例

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


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

示例1: http_DownloadStringCompleted

 private void http_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
 {
     try
     {
         File.WriteAllText(Utils.GetTempPath("gfwlist.txt"), e.Result, Encoding.UTF8);
         List<string> lines = ParseResult(e.Result);
         if (File.Exists(PACServer.USER_RULE_FILE))
         {
             string local = FileManager.NonExclusiveReadAllText(PACServer.USER_RULE_FILE, Encoding.UTF8);
             using (var sr = new StringReader(local))
             {
                 foreach (var rule in sr.NonWhiteSpaceLines())
                 {
                     if (rule.BeginWithAny(IgnoredLineBegins))
                         continue;
                     lines.Add(rule);
                 }
             }
         }
         string abpContent;
         if (File.Exists(PACServer.USER_ABP_FILE))
         {
             abpContent = FileManager.NonExclusiveReadAllText(PACServer.USER_ABP_FILE, Encoding.UTF8);
         }
         else
         {
             abpContent = Utils.UnGzip(Resources.abp_js);
         }
         abpContent = abpContent.Replace("__RULES__", JsonConvert.SerializeObject(lines, Formatting.Indented));
         if (File.Exists(PACServer.PAC_FILE))
         {
             string original = FileManager.NonExclusiveReadAllText(PACServer.PAC_FILE, Encoding.UTF8);
             if (original == abpContent)
             {
                 UpdateCompleted(this, new ResultEventArgs(false));
                 return;
             }
         }
         File.WriteAllText(PACServer.PAC_FILE, abpContent, Encoding.UTF8);
         if (UpdateCompleted != null)
         {
             UpdateCompleted(this, new ResultEventArgs(true));
         }
     }
     catch (Exception ex)
     {
         if (Error != null)
         {
             Error(this, new ErrorEventArgs(ex));
         }
     }
 }
开发者ID:shadowsocks,项目名称:shadowsocks-windows,代码行数:52,代码来源:GfwListUpdater.cs

示例2: ParseResult

 public static List<string> ParseResult(string response)
 {
     byte[] bytes = Convert.FromBase64String(response);
     string content = Encoding.ASCII.GetString(bytes);
     List<string> valid_lines = new List<string>();
     using (var sr = new StringReader(content))
     {
         foreach (var line in sr.NonWhiteSpaceLines())
         {
             if (line.BeginWithAny(IgnoredLineBegins))
                 continue;
             valid_lines.Add(line);
         }
     }
     return valid_lines;
 }
开发者ID:shadowsocks,项目名称:shadowsocks-windows,代码行数:16,代码来源:GfwListUpdater.cs

示例3: Init

        private static void Init(string res)
        {
            using (var sr = new StringReader(res))
            {
                foreach (var line in sr.NonWhiteSpaceLines())
                {
                    if (line[0] == '#')
                        continue;

                    var pos = line.IndexOf('=');
                    if (pos < 1)
                        continue;
                    _strings[line.Substring(0, pos)] = line.Substring(pos + 1);
                }
            }
        }
开发者ID:shadowsocks,项目名称:shadowsocks-windows,代码行数:16,代码来源:I18N.cs

示例4: I18N

        static I18N()
        {
            Strings = new Dictionary<string, string>();

            if (CultureInfo.CurrentCulture.IetfLanguageTag.StartsWith("zh", StringComparison.OrdinalIgnoreCase))
            {
                using (var sr = new StringReader(Resources.cn))
                {
                    foreach (var line in sr.NonWhiteSpaceLines())
                    {
                        if (line[0] == '#')
                            continue;

                        var pos = line.IndexOf('=');
                        if (pos < 1)
                            continue;
                        Strings[line.Substring(0, pos)] = line.Substring(pos + 1);
                    }
                }
            }
        }
开发者ID:CharlieQ1,项目名称:shadowsocks-windows,代码行数:21,代码来源:I18N.cs

示例5: pacServer_UserRuleFileChanged

 private void pacServer_UserRuleFileChanged(object sender, EventArgs e)
 {
     // TODO: this is a dirty hack. (from code GListUpdater.http_DownloadStringCompleted())
     if (!File.Exists(Utils.GetTempPath("gfwlist.txt")))
     {
         UpdatePACFromGFWList();
         return;
     }
     List<string> lines = GFWListUpdater.ParseResult(File.ReadAllText(Utils.GetTempPath("gfwlist.txt")));
     if (File.Exists(PACServer.USER_RULE_FILE))
     {
         string local = File.ReadAllText(PACServer.USER_RULE_FILE, Encoding.UTF8);
         using (var sr = new StringReader(local))
         {
             foreach (var rule in sr.NonWhiteSpaceLines())
             {
                 if (rule.BeginWithAny(IgnoredLineBegins))
                     continue;
                 lines.Add(rule);
             }
         }
     }
     string abpContent;
     if (File.Exists(PACServer.USER_ABP_FILE))
     {
         abpContent = File.ReadAllText(PACServer.USER_ABP_FILE, Encoding.UTF8);
     }
     else
     {
         abpContent = Utils.UnGzip(Resources.abp_js);
     }
     abpContent = abpContent.Replace("__RULES__", JsonConvert.SerializeObject(lines, Formatting.Indented));
     if (File.Exists(PACServer.PAC_FILE))
     {
         string original = File.ReadAllText(PACServer.PAC_FILE, Encoding.UTF8);
         if (original == abpContent)
         {
             return;
         }
     }
     File.WriteAllText(PACServer.PAC_FILE, abpContent, Encoding.UTF8);
 }
开发者ID:dantmnf,项目名称:shadowsocks-windows,代码行数:42,代码来源:ShadowsocksController.cs


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