本文整理汇总了C#中System.Xml.LineInfo类的典型用法代码示例。如果您正苦于以下问题:C# LineInfo类的具体用法?C# LineInfo怎么用?C# LineInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LineInfo类属于System.Xml命名空间,在下文中一共展示了LineInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DtdParserProxy_OnSystemId
internal void DtdParserProxy_OnSystemId(string systemId, LineInfo keywordLineInfo, LineInfo systemLiteralLineInfo)
{
NodeData attr = AddAttributeNoChecks("SYSTEM", _index + 1);
attr.SetValue(systemId);
attr.lineInfo = keywordLineInfo;
attr.lineInfo2 = systemLiteralLineInfo;
}
示例2: DtdParserProxy_OnPublicId
internal void DtdParserProxy_OnPublicId(string publicId, LineInfo keywordLineInfo, LineInfo publicLiteralLineInfo)
{
NodeData attr = AddAttributeNoChecks("PUBLIC", _index + 1);
attr.SetValue(publicId);
attr.lineInfo = keywordLineInfo;
attr.lineInfo2 = publicLiteralLineInfo;
}
示例3: AdjustLineInfo
static internal void AdjustLineInfo( char[] chars, int startPos, int endPos, bool isNormalized, ref LineInfo lineInfo ) {
int lastNewLinePos = -1;
int i = startPos;
while ( i < endPos ) {
switch ( chars[i] ) {
case '\n':
lineInfo.lineNo++;
lastNewLinePos = i;
break;
case '\r':
if ( isNormalized ) {
break;
}
lineInfo.lineNo++;
lastNewLinePos = i;
if ( i + 1 < endPos && chars[i+1] == '\n' ) {
i++;
lastNewLinePos++;
}
break;
}
i++;
}
if ( lastNewLinePos >= 0 ) {
lineInfo.linePos = endPos - lastNewLinePos;
}
}
示例4: ParseExternalIdAsync
private async Task< Tuple<string, string> > ParseExternalIdAsync(Token idTokenType, Token declType) {
Tuple<string, string> tuple;
string publicId;
string systemId;
LineInfo keywordLineInfo = new LineInfo( LineNo, LinePos - 6 );
publicId = null;
systemId = null;
if ( await GetTokenAsync( true ).ConfigureAwait(false) != Token.Literal ) {
ThrowUnexpectedToken( curPos, "\"", "'" );
}
if ( idTokenType == Token.SYSTEM ) {
systemId = GetValue();
if ( systemId.IndexOf( '#' ) >= 0 ) {
Throw( curPos - systemId.Length - 1, Res.Xml_FragmentId, new string[] { systemId.Substring( systemId.IndexOf( '#' ) ), systemId } );
}
if ( declType == Token.DOCTYPE && !freeFloatingDtd ) {
literalLineInfo.linePos++;
readerAdapter.OnSystemId( systemId, keywordLineInfo, literalLineInfo );
}
}
else {
Debug.Assert( idTokenType == Token.PUBLIC );
publicId = GetValue();
// verify if it contains chars valid for public ids
int i;
if ( ( i = xmlCharType.IsPublicId( publicId ) ) >= 0 ) {
ThrowInvalidChar( curPos - 1 - publicId.Length + i, publicId, i );
}
if ( declType == Token.DOCTYPE && !freeFloatingDtd ) {
literalLineInfo.linePos++;
readerAdapter.OnPublicId( publicId, keywordLineInfo, literalLineInfo );
if ( await GetTokenAsync( false ).ConfigureAwait(false) == Token.Literal ) {
if ( !whitespaceSeen ) {
Throw( Res.Xml_ExpectingWhiteSpace, new string( literalQuoteChar, 1 ), (int)literalLineInfo.lineNo, (int)literalLineInfo.linePos );
}
systemId = GetValue();
literalLineInfo.linePos++;
readerAdapter.OnSystemId( systemId, keywordLineInfo, literalLineInfo );
}
else {
ThrowUnexpectedToken( curPos, "\"", "'" );
}
}
else {
if ( await GetTokenAsync( false ).ConfigureAwait(false) == Token.Literal ) {
if ( !whitespaceSeen ) {
Throw( Res.Xml_ExpectingWhiteSpace, new string( literalQuoteChar, 1 ), (int)literalLineInfo.lineNo, (int)literalLineInfo.linePos );
}
systemId = GetValue();
}
else if ( declType != Token.NOTATION ) {
ThrowUnexpectedToken( curPos, "\"", "'" );
}
}
}
tuple = new Tuple<string, string>(publicId, systemId);
return tuple;
}
示例5: AdjustLineInfo
internal static unsafe void AdjustLineInfo(char* pChars, int length, bool isNormalized, ref LineInfo lineInfo)
{
int lastNewLinePos = -1;
for (int i = 0; i < length; i++)
{
switch (pChars[i])
{
case '\n':
lineInfo.lineNo++;
lastNewLinePos = i;
break;
case '\r':
if (isNormalized)
{
break;
}
lineInfo.lineNo++;
lastNewLinePos = i;
if (i + 1 < length && pChars[i + 1] == '\n')
{
i++;
lastNewLinePos++;
}
break;
}
}
if (lastNewLinePos >= 0)
{
lineInfo.linePos = length - lastNewLinePos;
}
}
示例6: ParseEndElementAsync_CheckEndTag
private Task ParseEndElementAsync_CheckEndTag(int nameLen, NodeData startTagNode, LineInfo endTagLineInfo) {
int pos;
char[] chars;
for (; ; ) {
pos = ps.charPos + nameLen;
chars = ps.chars;
if (pos == ps.charsUsed) {
parseEndElement_NextFunc = ParseEndElementParseFunction.ReadData;
return AsyncHelper.DoneTask;
}
bool tagMismatch = false;
unsafe {
#if SILVERLIGHT
if ( xmlCharType.IsNCNameSingleChar( chars[pos] ) ||
#else // Optimization due to the lack of inlining when a method uses byte*
if (((xmlCharType.charProperties[chars[pos]] & XmlCharType.fNCNameSC) != 0) ||
#endif
(chars[pos] == ':')
#if XML10_FIFTH_EDITION
|| xmlCharType.IsNCNameHighSurrogateChar( chars[pos] )
#endif
) {
tagMismatch = true;
}
}
if (tagMismatch) {
return ThrowTagMismatchAsync(startTagNode);
}
// eat whitespaces
if (chars[pos] != '>') {
char tmpCh;
while (xmlCharType.IsWhiteSpace(tmpCh = chars[pos])) {
pos++;
switch (tmpCh) {
case (char)0xA:
OnNewLine(pos);
continue;
case (char)0xD:
if (chars[pos] == (char)0xA) {
pos++;
}
else if (pos == ps.charsUsed && !ps.isEof) {
break;
}
OnNewLine(pos);
continue;
}
}
}
if (chars[pos] == '>') {
break;
}
else if (pos == ps.charsUsed) {
parseEndElement_NextFunc = ParseEndElementParseFunction.ReadData;
return AsyncHelper.DoneTask;
}
else {
ThrowUnexpectedToken(pos, ">");
}
Debug.Assert(false, "We should never get to this point.");
}
Debug.Assert(index > 0);
index--;
curNode = nodes[index];
// set the element data
Debug.Assert(curNode == startTagNode);
startTagNode.lineInfo = endTagLineInfo;
startTagNode.type = XmlNodeType.EndElement;
ps.charPos = pos + 1;
// set next parsing function
nextParsingFunction = (index > 0) ? parsingFunction : ParsingFunction.DocumentContent;
parsingFunction = ParsingFunction.PopElementContext;
parseEndElement_NextFunc = ParseEndElementParseFunction.Done;
return AsyncHelper.DoneTask;
}
示例7: ParseEndElementAsync_Finish
private async Task ParseEndElementAsync_Finish(Task task, int nameLen, NodeData startTagNode, LineInfo endTagLineInfo)
{
while (true)
{
await task.ConfigureAwait(false);
switch (_parseEndElement_NextFunc)
{
case ParseEndElementParseFunction.CheckEndTag:
task = ParseEndElementAsync_CheckEndTag(nameLen, startTagNode, endTagLineInfo);
break;
case ParseEndElementParseFunction.ReadData:
task = ParseEndElementAsync_ReadData();
break;
case ParseEndElementParseFunction.Done:
return;
}
}
}
示例8: ParseEndElementAsync_CheckNameAndParse
private Task ParseEndElementAsync_CheckNameAndParse()
{
NodeData startTagNode = _nodes[_index - 1];
int prefLen = startTagNode.prefix.Length;
int locLen = startTagNode.localName.Length;
int nameLen;
char[] chars = _ps.chars;
if (startTagNode.prefix.Length == 0)
{
if (!XmlConvert.StrEqual(chars, _ps.charPos, locLen, startTagNode.localName))
{
return ThrowTagMismatchAsync(startTagNode);
}
nameLen = locLen;
}
else
{
int colonPos = _ps.charPos + prefLen;
if (!XmlConvert.StrEqual(chars, _ps.charPos, prefLen, startTagNode.prefix) ||
chars[colonPos] != ':' ||
!XmlConvert.StrEqual(chars, colonPos + 1, locLen, startTagNode.localName))
{
return ThrowTagMismatchAsync(startTagNode);
}
nameLen = locLen + prefLen + 1;
}
LineInfo endTagLineInfo = new LineInfo(_ps.lineNo, _ps.LinePos);
return ParseEndElementAsync_Finish(nameLen, startTagNode, endTagLineInfo);
}
示例9:
void IDtdParserAdapter.OnPublicId( string publicId, LineInfo keywordLineInfo, LineInfo publicLiteralLineInfo ) {
reader.DtdParserProxy_OnPublicId( publicId, keywordLineInfo, publicLiteralLineInfo );
}
示例10: ParseAttributeValueSlowAsync
private async Task ParseAttributeValueSlowAsync( int curPos, char quoteChar, NodeData attr ) {
int pos = curPos;
char[] chars = ps.chars;
int attributeBaseEntityId = ps.entityId;
#if !SILVERLIGHT // Needed only for XmlTextReader (reporting of entities)
int valueChunkStartPos = 0;
LineInfo valueChunkLineInfo = new LineInfo(ps.lineNo, ps.LinePos);
NodeData lastChunk = null;
#endif
Debug.Assert( stringBuilder.Length == 0 );
for (;;) {
// parse the rest of the attribute value
#if SILVERLIGHT
while (xmlCharType.IsAttributeValueChar(chars[pos])) {
pos++;
}
#else // Optimization due to the lack of inlining when a method uses byte*
unsafe {
while (((xmlCharType.charProperties[chars[pos]] & XmlCharType.fAttrValue) != 0)) {
pos++;
}
}
#endif
if ( pos - ps.charPos > 0 ) {
stringBuilder.Append( chars, ps.charPos, pos - ps.charPos );
ps.charPos = pos;
}
if ( chars[pos] == quoteChar && attributeBaseEntityId == ps.entityId ) {
break;
}
else {
switch ( chars[pos] ) {
// eol
case (char)0xA:
pos++;
OnNewLine( pos );
if ( normalize ) {
stringBuilder.Append( (char)0x20 ); // CDATA normalization of 0xA
ps.charPos++;
}
continue;
case (char)0xD:
if ( chars[pos+1] == (char)0xA ) {
pos += 2;
if ( normalize ) {
stringBuilder.Append( ps.eolNormalized ? "\u0020\u0020" : "\u0020" ); // CDATA normalization of 0xD 0xA
ps.charPos = pos;
}
}
else if ( pos+1 < ps.charsUsed || ps.isEof ) {
pos++;
if ( normalize ) {
stringBuilder.Append( (char)0x20 ); // CDATA normalization of 0xD and 0xD 0xA
ps.charPos = pos;
}
}
else {
goto ReadData;
}
OnNewLine( pos );
continue;
// tab
case (char)0x9:
pos++;
if ( normalize ) {
stringBuilder.Append( (char)0x20 ); // CDATA normalization of 0x9
ps.charPos++;
}
continue;
case '"':
case '\'':
case '>':
pos++;
continue;
// attribute values cannot contain '<'
case '<':
Throw( pos, Res.Xml_BadAttributeChar, XmlException.BuildCharExceptionArgs( '<', '\0' ) );
break;
// entity referece
case '&':
if ( pos - ps.charPos > 0 ) {
stringBuilder.Append( chars, ps.charPos, pos - ps.charPos );
}
ps.charPos = pos;
#if !SILVERLIGHT // Needed only for XmlTextReader (reporting of entities)
int enclosingEntityId = ps.entityId;
LineInfo entityLineInfo = new LineInfo( ps.lineNo, ps.LinePos + 1 );
#endif
var tuple_8 = await HandleEntityReferenceAsync( true, EntityExpandType.All).ConfigureAwait(false);
pos = tuple_8.Item1;
switch ( tuple_8.Item2 ) {
case EntityType.CharacterDec:
//.........这里部分代码省略.........
示例11: ParseEndElement
// parses the element end tag
private void ParseEndElement()
{
// check if the end tag name equals start tag name
NodeData startTagNode = _nodes[_index - 1];
int prefLen = startTagNode.prefix.Length;
int locLen = startTagNode.localName.Length;
while (_ps.charsUsed - _ps.charPos < prefLen + locLen + 1)
{
if (ReadData() == 0)
{
break;
}
}
int nameLen;
char[] chars = _ps.chars;
if (startTagNode.prefix.Length == 0)
{
if (!XmlConvert.StrEqual(chars, _ps.charPos, locLen, startTagNode.localName))
{
ThrowTagMismatch(startTagNode);
}
nameLen = locLen;
}
else
{
int colonPos = _ps.charPos + prefLen;
if (!XmlConvert.StrEqual(chars, _ps.charPos, prefLen, startTagNode.prefix) ||
chars[colonPos] != ':' ||
!XmlConvert.StrEqual(chars, colonPos + 1, locLen, startTagNode.localName))
{
ThrowTagMismatch(startTagNode);
}
nameLen = locLen + prefLen + 1;
}
LineInfo endTagLineInfo = new LineInfo(_ps.lineNo, _ps.LinePos);
int pos;
for (;;)
{
pos = _ps.charPos + nameLen;
chars = _ps.chars;
if (pos == _ps.charsUsed)
{
goto ReadData;
}
unsafe
{
if (_xmlCharType.IsNCNameSingleChar(chars[pos]) || (chars[pos] == ':')
#if XML10_FIFTH_EDITION
|| xmlCharType.IsNCNameHighSurrogateChar(chars[pos])
#endif
)
{
ThrowTagMismatch(startTagNode);
}
}
// eat whitespaces
if (chars[pos] != '>')
{
char tmpCh;
while (_xmlCharType.IsWhiteSpace(tmpCh = chars[pos]))
{
pos++;
switch (tmpCh)
{
case (char)0xA:
OnNewLine(pos);
continue;
case (char)0xD:
if (chars[pos] == (char)0xA)
{
pos++;
}
else if (pos == _ps.charsUsed && !_ps.isEof)
{
break;
}
OnNewLine(pos);
continue;
}
}
}
if (chars[pos] == '>')
{
break;
}
else if (pos == _ps.charsUsed)
{
goto ReadData;
}
else
//.........这里部分代码省略.........
示例12: ParseEndElementAsync_CheckEndTag
private Task ParseEndElementAsync_CheckEndTag(int nameLen, NodeData startTagNode, LineInfo endTagLineInfo)
{
int pos;
char[] chars;
for (; ;)
{
pos = _ps.charPos + nameLen;
chars = _ps.chars;
if (pos == _ps.charsUsed)
{
_parseEndElement_NextFunc = ParseEndElementParseFunction.ReadData;
return Task.CompletedTask;
}
bool tagMismatch = false;
unsafe
{
if (_xmlCharType.IsNCNameSingleChar(chars[pos]) || (chars[pos] == ':')
#if XML10_FIFTH_EDITION
|| xmlCharType.IsNCNameHighSurrogateChar(chars[pos])
#endif
)
{
tagMismatch = true;
}
}
if (tagMismatch)
{
return ThrowTagMismatchAsync(startTagNode);
}
// eat whitespaces
if (chars[pos] != '>')
{
char tmpCh;
while (_xmlCharType.IsWhiteSpace(tmpCh = chars[pos]))
{
pos++;
switch (tmpCh)
{
case (char)0xA:
OnNewLine(pos);
continue;
case (char)0xD:
if (chars[pos] == (char)0xA)
{
pos++;
}
else if (pos == _ps.charsUsed && !_ps.isEof)
{
break;
}
OnNewLine(pos);
continue;
}
}
}
if (chars[pos] == '>')
{
break;
}
else if (pos == _ps.charsUsed)
{
_parseEndElement_NextFunc = ParseEndElementParseFunction.ReadData;
return Task.CompletedTask;
}
else
{
ThrowUnexpectedToken(pos, ">");
}
Debug.Assert(false, "We should never get to this point.");
}
Debug.Assert(_index > 0);
_index--;
_curNode = _nodes[_index];
// set the element data
Debug.Assert(_curNode == startTagNode);
startTagNode.lineInfo = endTagLineInfo;
startTagNode.type = XmlNodeType.EndElement;
_ps.charPos = pos + 1;
// set next parsing function
_nextParsingFunction = (_index > 0) ? _parsingFunction : ParsingFunction.DocumentContent;
_parsingFunction = ParsingFunction.PopElementContext;
_parseEndElement_NextFunc = ParseEndElementParseFunction.Done;
return Task.CompletedTask;
}
示例13: ParseAttributeValueSlow
private void ParseAttributeValueSlow(int curPos, char quoteChar, NodeData attr)
{
int pos = curPos;
char[] chars = _ps.chars;
int attributeBaseEntityId = _ps.entityId;
int valueChunkStartPos = 0;
LineInfo valueChunkLineInfo = new LineInfo(_ps.lineNo, _ps.LinePos);
NodeData lastChunk = null;
Debug.Assert(_stringBuilder.Length == 0);
for (;;)
{
// parse the rest of the attribute value
unsafe
{
while (_xmlCharType.IsAttributeValueChar(chars[pos]))
{
pos++;
}
}
if (pos - _ps.charPos > 0)
{
_stringBuilder.Append(chars, _ps.charPos, pos - _ps.charPos);
_ps.charPos = pos;
}
if (chars[pos] == quoteChar && attributeBaseEntityId == _ps.entityId)
{
break;
}
else
{
switch (chars[pos])
{
// eol
case (char)0xA:
pos++;
OnNewLine(pos);
if (_normalize)
{
_stringBuilder.Append((char)0x20); // CDATA normalization of 0xA
_ps.charPos++;
}
continue;
case (char)0xD:
if (chars[pos + 1] == (char)0xA)
{
pos += 2;
if (_normalize)
{
_stringBuilder.Append(_ps.eolNormalized ? "\u0020\u0020" : "\u0020"); // CDATA normalization of 0xD 0xA
_ps.charPos = pos;
}
}
else if (pos + 1 < _ps.charsUsed || _ps.isEof)
{
pos++;
if (_normalize)
{
_stringBuilder.Append((char)0x20); // CDATA normalization of 0xD and 0xD 0xA
_ps.charPos = pos;
}
}
else
{
goto ReadData;
}
OnNewLine(pos);
continue;
// tab
case (char)0x9:
pos++;
if (_normalize)
{
_stringBuilder.Append((char)0x20); // CDATA normalization of 0x9
_ps.charPos++;
}
continue;
case '"':
case '\'':
case '>':
pos++;
continue;
// attribute values cannot contain '<'
case '<':
Throw(pos, SR.Xml_BadAttributeChar, XmlException.BuildCharExceptionArgs('<', '\0'));
break;
// entity referece
case '&':
if (pos - _ps.charPos > 0)
{
_stringBuilder.Append(chars, _ps.charPos, pos - _ps.charPos);
}
_ps.charPos = pos;
int enclosingEntityId = _ps.entityId;
LineInfo entityLineInfo = new LineInfo(_ps.lineNo, _ps.LinePos + 1);
switch (HandleEntityReference(true, EntityExpandType.All, out pos))
//.........这里部分代码省略.........
示例14: ParseAttributeValueSlow
private void ParseAttributeValueSlow(int curPos, char quoteChar, NodeData attr)
{
int pos = curPos;
char[] chars = ps.chars;
int valueChunkStartPos = 0;
LineInfo valueChunkLineInfo = new LineInfo(ps.lineNo, ps.LinePos);
NodeData lastChunk = null;
Debug.Assert(stringBuilder.Length == 0);
for (; ; )
{
// parse the rest of the attribute value
while (chars[pos] > XmlCharType.MaxAsciiChar || (xmlCharType.charProperties[chars[pos]] & XmlCharType.fAttrValue) != 0)
{
pos++;
}
if (pos - ps.charPos > 0)
{
stringBuilder.Append(chars, ps.charPos, pos - ps.charPos);
ps.charPos = pos;
}
if (chars[pos] == quoteChar)
{
break;
}
else
{
switch (chars[pos])
{
// eol
case (char)0xA:
pos++;
OnNewLine(pos);
if (normalize)
{
stringBuilder.Append((char)0x20); // CDATA normalization of 0xA
ps.charPos++;
}
continue;
case (char)0xD:
if (chars[pos + 1] == (char)0xA)
{
pos += 2;
if (normalize)
{
stringBuilder.Append(ps.eolNormalized ? "\u0020\u0020" : "\u0020"); // CDATA normalization of 0xD 0xA
ps.charPos = pos;
}
}
else if (pos + 1 < ps.charsUsed || ps.isEof)
{
pos++;
if (normalize)
{
stringBuilder.Append((char)0x20); // CDATA normalization of 0xD and 0xD 0xA
ps.charPos = pos;
}
}
else
{
goto ReadData;
}
OnNewLine(pos);
continue;
// tab
case (char)0x9:
pos++;
if (normalize)
{
stringBuilder.Append((char)0x20); // CDATA normalization of 0x9
ps.charPos++;
}
continue;
case '"':
case '\'':
case '>':
pos++;
continue;
// attribute values cannot contain '<'
case '<':
Throw(pos, Res.Xml_BadAttributeChar, XmlException.BuildCharExceptionStr('<'));
break;
// entity referece
case '&':
if (pos - ps.charPos > 0)
{
stringBuilder.Append(chars, ps.charPos, pos - ps.charPos);
}
ps.charPos = pos;
LineInfo entityLineInfo = new LineInfo(ps.lineNo, ps.LinePos + 1);
switch (HandleEntityReference(true, EntityExpandType.All, out pos))
{
case EntityType.CharacterDec:
case EntityType.CharacterHex:
//.........这里部分代码省略.........
示例15: AdjustLineInfo
internal void AdjustLineInfo(int valueOffset, bool isNormalized, ref LineInfo lineInfo)
{
if (valueOffset == 0)
{
return;
}
if (valueStartPos != -1)
{
XmlTextReader.AdjustLineInfo(chars, valueStartPos, valueStartPos + valueOffset, isNormalized, ref lineInfo);
}
else
{
char[] chars = value.Substring(0, valueOffset).ToCharArray();
XmlTextReader.AdjustLineInfo(chars, 0, chars.Length, isNormalized, ref lineInfo);
}
}