本文整理汇总了C#中StringParser.MoveAndExtractNextInOuterParens方法的典型用法代码示例。如果您正苦于以下问题:C# StringParser.MoveAndExtractNextInOuterParens方法的具体用法?C# StringParser.MoveAndExtractNextInOuterParens怎么用?C# StringParser.MoveAndExtractNextInOuterParens使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringParser
的用法示例。
在下文中一共展示了StringParser.MoveAndExtractNextInOuterParens方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestExtractingStringFromParentheses
public void TestExtractingStringFromParentheses()
{
string buffer = "This(is a unicode \u0020)something,(89),(haha123blah)After brace,";
char separator = ',';
StringParser sp = new StringParser(buffer, separator);
Assert.Throws<InvalidDataException>(() => sp.MoveAndExtractNextInOuterParens());
Assert.Equal("This(is a unicode \u0020)something", sp.ExtractCurrent());
Assert.Equal("89),(haha123blah", sp.MoveAndExtractNextInOuterParens());
Assert.Equal("(89),(haha123blah)", sp.ExtractCurrent());
Assert.Equal("fter brace", sp.MoveAndExtractNext());
Assert.Equal("", sp.MoveAndExtractNext());
}
示例2: TryParseStatFile
internal static bool TryParseStatFile(string statFilePath, out ParsedStat result, ReusableTextReader reusableReader)
{
string statFileContents;
try
{
using (var source = new FileStream(statFilePath, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize: 1, useAsync: false))
{
statFileContents = reusableReader.ReadAllText(source);
}
}
catch (IOException)
{
// Between the time that we get an ID and the time that we try to read the associated stat
// file(s), the process could be gone.
result = default(ParsedStat);
return false;
}
var parser = new StringParser(statFileContents, ' ');
var results = default(ParsedStat);
results.pid = parser.ParseNextInt32();
results.comm = parser.MoveAndExtractNextInOuterParens();
results.state = parser.ParseNextChar();
parser.MoveNextOrFail(); // ppid
parser.MoveNextOrFail(); // pgrp
results.session = parser.ParseNextInt32();
parser.MoveNextOrFail(); // tty_nr
parser.MoveNextOrFail(); // tpgid
parser.MoveNextOrFail(); // flags
parser.MoveNextOrFail(); // majflt
parser.MoveNextOrFail(); // cmagflt
parser.MoveNextOrFail(); // minflt
parser.MoveNextOrFail(); // cminflt
results.utime = parser.ParseNextUInt64();
results.stime = parser.ParseNextUInt64();
parser.MoveNextOrFail(); // cutime
parser.MoveNextOrFail(); // cstime
parser.MoveNextOrFail(); // priority
results.nice = parser.ParseNextInt64();
parser.MoveNextOrFail(); // num_threads
parser.MoveNextOrFail(); // itrealvalue
results.starttime = parser.ParseNextUInt64();
results.vsize = parser.ParseNextUInt64();
results.rss = parser.ParseNextInt64();
results.rsslim = parser.ParseNextUInt64();
// The following lines are commented out as there's no need to parse through
// the rest of the entry (we've gotten all of the data we need). Should any
// of these fields be needed in the future, uncomment all of the lines up
// through and including the one that's needed. For now, these are being left
// commented to document what's available in the remainder of the entry.
//parser.MoveNextOrFail(); // startcode
//parser.MoveNextOrFail(); // endcode
//parser.MoveNextOrFail(); // startstack
//parser.MoveNextOrFail(); // kstkesp
//parser.MoveNextOrFail(); // kstkeip
//parser.MoveNextOrFail(); // signal
//parser.MoveNextOrFail(); // blocked
//parser.MoveNextOrFail(); // sigignore
//parser.MoveNextOrFail(); // sigcatch
//parser.MoveNextOrFail(); // wchan
//parser.MoveNextOrFail(); // nswap
//parser.MoveNextOrFail(); // cnswap
//parser.MoveNextOrFail(); // exit_signal
//parser.MoveNextOrFail(); // processor
//parser.MoveNextOrFail(); // rt_priority
//parser.MoveNextOrFail(); // policy
//parser.MoveNextOrFail(); // delayacct_blkio_ticks
//parser.MoveNextOrFail(); // guest_time
//parser.MoveNextOrFail(); // cguest_time
result = results;
return true;
}