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


C# StringParser.ExtractCurrentToEnd方法代码示例

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


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

示例1: TestExtractCurrentToEnd

 public void TestExtractCurrentToEnd()
 {
     string buffer = "This has a /path/to my favorite file/with a space";
     char separator = ' ';
     StringParser sp = new StringParser(buffer, separator);
     Assert.Equal("This", sp.MoveAndExtractNext());
     Assert.Equal("has", sp.MoveAndExtractNext());
     Assert.Equal("a", sp.MoveAndExtractNext());
     Assert.True(sp.MoveNext());
     Assert.Equal("/path/to my favorite file/with a space", sp.ExtractCurrentToEnd());
 }
开发者ID:dotnet,项目名称:corefx,代码行数:11,代码来源:StringParserTests.cs

示例2: ParseMapsModulesCore

        private static IEnumerable<ParsedMapsModule> ParseMapsModulesCore(IEnumerable<string> lines)
        {
            Debug.Assert(lines != null);

            // Parse each line from the maps file into a ParsedMapsModule result
            foreach (string line in lines)
            {
                // Use a StringParser to avoid string.Split costs
                var parser = new StringParser(line, separator: ' ', skipEmpty: true);

                // Parse the address range 
                KeyValuePair<long, long> addressRange =  
                    parser.ParseRaw(delegate (string s, ref int start, ref int end)
                    {
                        long startingAddress = 0, endingAddress = 0;
                        int pos = s.IndexOf('-', start, end - start);
                        if (pos > 0)
                        {
                            string startingString = s.Substring(start, pos);
                            if (long.TryParse(startingString, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out startingAddress))
                            {
                                string endingString = s.Substring(pos + 1, end - (pos + 1));
                                long.TryParse(endingString, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out endingAddress);
                            }
                        }
                        return new KeyValuePair<long, long>(startingAddress, endingAddress);
                    });

                // Parse the permissions (we only care about entries with 'r' and 'x' set)
                if (!parser.ParseRaw(delegate (string s, ref int start, ref int end)
                {
                    bool sawRead = false, sawExec = false;
                    for (int i = start; i < end; i++)
                    {
                        if (s[i] == 'r')
                            sawRead = true;
                        else if (s[i] == 'x')
                            sawExec = true;
                    }
                    return sawRead & sawExec;
                }))
                {
                    continue;
                }

                // Skip past the offset, dev, and inode fields
                parser.MoveNext();
                parser.MoveNext();
                parser.MoveNext();

                // Parse the pathname
                if (!parser.MoveNext())
                {
                    continue;
                }
                string pathname = parser.ExtractCurrentToEnd();

                // We only get here if a we have a non-empty pathname and
                // the permissions included both readability and executability.
                // Yield the result.
                yield return new ParsedMapsModule { FileName = pathname, AddressRange = addressRange };
            }
        }
开发者ID:dotnet,项目名称:corefx,代码行数:63,代码来源:Interop.ProcFsStat.cs


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