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


C# ITextSnapshot.ReadPropertyValue方法代码示例

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


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

示例1: Parse


//.........这里部分代码省略.........

                    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
                    snapshot.ReadWhiteSpace(ref cursor);
                    SnapshotToken nameValueDelimiter = new SnapshotToken(snapshot.ReadExact(ref cursor, RegistrySyntaxFacts.PropertyNameValueDelimiter), _delimiterType);
                    snapshot.ReadWhiteSpace(ref cursor);

                    // delete token
                    SnapshotToken deleteToken = new SnapshotToken(snapshot.ReadExact(ref cursor, RegistrySyntaxFacts.DeleteKey), _operatorType);
                    snapshot.ReadWhiteSpace(ref cursor);

                    SnapshotToken valueOpeningQuote = new SnapshotToken(snapshot.ReadExact(ref cursor, RegistrySyntaxFacts.Quote), _stringType);

                    // read type
                    SnapshotSpan typeSpan = snapshot.ReadType(ref cursor);

                    bool readType = !typeSpan.IsEmpty && RegistrySyntaxFacts.IsKnownDataTypeNameOrShortcut(typeSpan.GetText());

                    SnapshotToken type = readType ? new SnapshotToken(typeSpan, _typeType) : SnapshotToken.CreateMissing(cursor, _typeType);
                    SnapshotToken typeSpecifierOpeningBrace = readType ? new SnapshotToken(snapshot.ReadExact(ref cursor, RegistrySyntaxFacts.TypeSpecifierOpeningBrace), _typeType) : SnapshotToken.CreateMissing(cursor, _typeType);
                    SnapshotToken typeSpecifier = readType ? new SnapshotToken(snapshot.ReadTypeSpecifier(ref cursor), _typeType) : SnapshotToken.CreateMissing(cursor, _typeType);
                    SnapshotToken typeSpecifierClosingBrace = readType ? new SnapshotToken(snapshot.ReadExact(ref cursor, RegistrySyntaxFacts.TypeSpecifierClosingBrace), _typeType) : SnapshotToken.CreateMissing(cursor, _typeType);

                    SnapshotToken typeValueDelimiter = readType ? new SnapshotToken(snapshot.ReadExact(ref cursor, RegistrySyntaxFacts.TypeValueDelimiter), _delimiterType) : SnapshotToken.CreateMissing(cursor, _typeType);

                    if (!readType)
                        cursor = typeSpan.Start;

                    // read value
                    SnapshotToken value = new SnapshotToken(snapshot.ReadPropertyValue(ref cursor), type.IsMissing ? _stringType : _propertyValueType);
                    SnapshotToken valueClosingQuote = new SnapshotToken(snapshot.ReadExact(ref cursor, RegistrySyntaxFacts.Quote), _stringType);

                    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);

                    RegistryPropertySyntax property = new RegistryPropertySyntax()
                    {
                        Section = section,
                        LeadingTrivia = leadingTrivia,
                        NameOpeningQuoteToken = nameOpeningQuote,
                        NameToken = name,
                        NameClosingQuoteToken = nameClosingQuote,
                        NameValueDelimiterToken = nameValueDelimiter,
                        DeleteToken = deleteToken,
                        ValueOpeningQuoteToken = valueOpeningQuote,
                        TypeToken = type,
                        TypeSpecifierOpeningBraceToken = typeSpecifierOpeningBrace,
                        TypeSpecifierToken = typeSpecifier,
                        TypeSpecifierClosingBraceToken = typeSpecifierClosingBrace,
                        TypeValueDelimiterToken = typeValueDelimiter,
                        ValueToken = value,
                        ValueClosingQuoteToken = valueClosingQuote,
                        TrailingTrivia = trailingTrivia,
                    };
                    section.Properties.Add(property);
                    leadingTrivia = new List<SnapshotToken>();
                }

                // error
                else
                    ; // TODO: report error
            }

            if (section != null && leadingTrivia.Any())
                foreach (var trivia in leadingTrivia)
                    section.TrailingTrivia.Add(trivia);

            if (section != null)
                root.Sections.Add(section);

            return new SyntaxTree(snapshot, root);
        }
开发者ID:Peter-Juhasz,项目名称:RegistryLanguageService,代码行数:101,代码来源:RegistrySyntacticParser.cs


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