本文整理汇总了C#中ITextSnapshot.ReadPropertyName方法的典型用法代码示例。如果您正苦于以下问题:C# ITextSnapshot.ReadPropertyName方法的具体用法?C# ITextSnapshot.ReadPropertyName怎么用?C# ITextSnapshot.ReadPropertyName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITextSnapshot
的用法示例。
在下文中一共展示了ITextSnapshot.ReadPropertyName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
public SyntaxTree Parse(ITextSnapshot snapshot)
{
RegistryDocumentSyntax root = new RegistryDocumentSyntax() { Snapshot = snapshot };
List<SnapshotToken> leadingTrivia = new List<SnapshotToken>();
RegistrySectionSyntax section = null;
foreach (ITextSnapshotLine line in snapshot.Lines)
{
SnapshotPoint cursor = line.Start;
snapshot.ReadWhiteSpace(ref cursor); // skip white space
// read version
if (line.LineNumber == 0)
{
SnapshotToken versionToken = new SnapshotToken(snapshot.ReadToCommentOrLineEndWhile(ref cursor, _ => true), _versionType);
snapshot.ReadWhiteSpace(ref cursor);
root.VersionToken = versionToken;
if (snapshot.IsAtExact(cursor, RegistrySyntaxFacts.Comment))
{
SnapshotToken commentToken = new SnapshotToken(snapshot.ReadComment(ref cursor), _commentType);
leadingTrivia.Add(commentToken);
}
continue;
}
// skip blank lines
if (cursor == line.End)
continue;
char first = cursor.GetChar();
// comment
if (first == RegistrySyntaxFacts.Comment)
{
SnapshotToken commentToken = new SnapshotToken(snapshot.ReadComment(ref cursor), _commentType);
leadingTrivia.Add(commentToken);
}
// section
else if (first == RegistrySyntaxFacts.SectionNameOpeningBracket)
{
if (section != null)
root.Sections.Add(section);
SnapshotToken deleteToken = new SnapshotToken(snapshot.ReadExact(ref cursor, RegistrySyntaxFacts.DeleteKey), _operatorType);
snapshot.ReadWhiteSpace(ref cursor);
SnapshotToken openingBracket = new SnapshotToken(snapshot.ReadExact(ref cursor, RegistrySyntaxFacts.SectionNameOpeningBracket), _delimiterType);
snapshot.ReadWhiteSpace(ref cursor);
// read key
SeparatedTokenListSyntax path = new SeparatedTokenListSyntax() { Section = section };
SnapshotToken name = new SnapshotToken(snapshot.ReadSectionName(ref cursor), _sectionNameType);
path.Tokens.Add(name);
snapshot.ReadWhiteSpace(ref cursor);
while (snapshot.IsAtExact(cursor, RegistrySyntaxFacts.KeySeparator))
{
SnapshotToken separator = new SnapshotToken(snapshot.ReadExact(ref cursor, RegistrySyntaxFacts.KeySeparator), _sectionNameType);
path.Separators.Add(separator);
snapshot.ReadWhiteSpace(ref cursor);
name = new SnapshotToken(snapshot.ReadSectionName(ref cursor), _sectionNameType);
path.Tokens.Add(name);
snapshot.ReadWhiteSpace(ref cursor);
}
SnapshotToken closingBracket = new SnapshotToken(snapshot.ReadExact(ref cursor, RegistrySyntaxFacts.SectionNameClosingBracket), _delimiterType);
snapshot.ReadWhiteSpace(ref cursor);
SnapshotToken commentToken = new SnapshotToken(snapshot.ReadComment(ref cursor), _commentType);
IList<SnapshotToken> trailingTrivia = new List<SnapshotToken>();
if (!commentToken.IsMissing)
trailingTrivia.Add(commentToken);
section = new RegistrySectionSyntax()
{
Document = root,
LeadingTrivia = leadingTrivia,
DeleteToken = deleteToken,
OpeningBracketToken = openingBracket,
NameSyntax = path,
ClosingBracketToken = closingBracket,
TrailingTrivia = trailingTrivia,
};
leadingTrivia = new List<SnapshotToken>();
}
// property
else if (Char.IsLetter(first) || first == RegistrySyntaxFacts.Quote)
{
// read key name
SnapshotToken nameOpeningQuote = new SnapshotToken(snapshot.ReadExact(ref cursor, RegistrySyntaxFacts.Quote), _stringType);
SnapshotToken name = new SnapshotToken(snapshot.ReadPropertyName(ref cursor), _propertyNameType);
SnapshotToken nameClosingQuote = new SnapshotToken(snapshot.ReadExact(ref cursor, RegistrySyntaxFacts.Quote), _stringType);
// delimiter
//.........这里部分代码省略.........