Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ParseAttributeValueSlowAsync()

async Task System.Xml.XmlTextReaderImpl.ParseAttributeValueSlowAsync ( int curPos,
char quoteChar,
NodeData attr )
inlineprivate

Definition at line 10677 of file XmlTextReaderImpl.cs.

10678 {
10679 int pos = curPos;
10680 char[] chars = _ps.chars;
10682 int valueChunkStartPos = 0;
10683 LineInfo valueChunkLineInfo = new LineInfo(_ps.lineNo, _ps.LinePos);
10684 NodeData lastChunk = null;
10685 while (true)
10686 {
10687 if (XmlCharType.IsAttributeValueChar(chars[pos]))
10688 {
10689 pos++;
10690 continue;
10691 }
10692 if (pos - _ps.charPos > 0)
10693 {
10695 _ps.charPos = pos;
10696 }
10697 if (chars[pos] == quoteChar && attributeBaseEntityId == _ps.entityId)
10698 {
10699 break;
10700 }
10701 switch (chars[pos])
10702 {
10703 case '\n':
10704 pos++;
10705 OnNewLine(pos);
10706 if (_normalize)
10707 {
10709 _ps.charPos++;
10710 }
10711 continue;
10712 case '\r':
10713 if (chars[pos + 1] == '\n')
10714 {
10715 pos += 2;
10716 if (_normalize)
10717 {
10719 _ps.charPos = pos;
10720 }
10721 }
10722 else
10723 {
10724 if (pos + 1 >= _ps.charsUsed && !_ps.isEof)
10725 {
10726 break;
10727 }
10728 pos++;
10729 if (_normalize)
10730 {
10732 _ps.charPos = pos;
10733 }
10734 }
10735 OnNewLine(pos);
10736 continue;
10737 case '\t':
10738 pos++;
10739 if (_normalize)
10740 {
10742 _ps.charPos++;
10743 }
10744 continue;
10745 case '"':
10746 case '\'':
10747 case '>':
10748 pos++;
10749 continue;
10750 case '<':
10751 Throw(pos, System.SR.Xml_BadAttributeChar, XmlException.BuildCharExceptionArgs('<', '\0'));
10752 break;
10753 case '&':
10754 {
10755 if (pos - _ps.charPos > 0)
10756 {
10758 }
10759 _ps.charPos = pos;
10761 LineInfo entityLineInfo = new LineInfo(_ps.lineNo, _ps.LinePos + 1);
10763 (pos, _) = tuple;
10764 switch (tuple.Item2)
10765 {
10766 case EntityType.Unexpanded:
10767 if (_parsingMode == ParsingMode.Full && _ps.entityId == attributeBaseEntityId)
10768 {
10770 if (num2 > 0)
10771 {
10772 NodeData nodeData3 = new NodeData();
10775 nodeData3.SetValueNode(XmlNodeType.Text, _stringBuilder.ToString(valueChunkStartPos, num2));
10777 }
10778 _ps.charPos++;
10780 NodeData nodeData4 = new NodeData();
10783 nodeData4.SetNamedNode(XmlNodeType.EntityReference, text);
10790 _fullAttrCleanup = true;
10791 }
10792 else
10793 {
10794 _ps.charPos++;
10796 }
10797 pos = _ps.charPos;
10798 break;
10799 case EntityType.ExpandedInAttribute:
10800 if (_parsingMode == ParsingMode.Full && enclosingEntityId == attributeBaseEntityId)
10801 {
10803 if (num > 0)
10804 {
10805 NodeData nodeData = new NodeData();
10808 nodeData.SetValueNode(XmlNodeType.Text, _stringBuilder.ToString(valueChunkStartPos, num));
10810 }
10811 NodeData nodeData2 = new NodeData();
10814 nodeData2.SetNamedNode(XmlNodeType.EntityReference, _ps.entity.Name);
10816 _fullAttrCleanup = true;
10817 }
10818 pos = _ps.charPos;
10819 break;
10820 default:
10821 pos = _ps.charPos;
10822 break;
10823 case EntityType.CharacterDec:
10824 case EntityType.CharacterHex:
10825 case EntityType.CharacterNamed:
10826 break;
10827 }
10828 chars = _ps.chars;
10829 continue;
10830 }
10831 default:
10832 {
10833 if (pos == _ps.charsUsed)
10834 {
10835 break;
10836 }
10837 char ch = chars[pos];
10838 if (XmlCharType.IsHighSurrogate(ch))
10839 {
10840 if (pos + 1 == _ps.charsUsed)
10841 {
10842 break;
10843 }
10844 pos++;
10845 if (XmlCharType.IsLowSurrogate(chars[pos]))
10846 {
10847 pos++;
10848 continue;
10849 }
10850 }
10852 break;
10853 }
10854 }
10855 if (await ReadDataAsync().ConfigureAwait(continueOnCapturedContext: false) == 0)
10856 {
10857 if (_ps.charsUsed - _ps.charPos > 0)
10858 {
10859 if (_ps.chars[_ps.charPos] != '\r')
10860 {
10862 }
10863 }
10864 else
10865 {
10866 if (!InEntity)
10867 {
10868 if (_fragmentType == XmlNodeType.Attribute)
10869 {
10871 {
10873 }
10874 break;
10875 }
10877 }
10879 {
10881 }
10883 {
10886 }
10887 }
10888 }
10889 pos = _ps.charPos;
10890 chars = _ps.chars;
10891 }
10892 if (attr.nextAttrValueChunk != null)
10893 {
10895 if (num3 > 0)
10896 {
10897 NodeData nodeData5 = new NodeData();
10900 nodeData5.SetValueNode(XmlNodeType.Text, _stringBuilder.ToString(valueChunkStartPos, num3));
10902 }
10903 }
10904 _ps.charPos = pos + 1;
10905 attr.SetValue(_stringBuilder.ToString());
10907 }
static string Xml_BadAttributeChar
Definition SR.cs:74
static string Xml_UnexpectedEOF1
Definition SR.cs:38
static string Xml_UnclosedQuote
Definition SR.cs:34
static string Xml_EntityRefNesting
Definition SR.cs:140
static string Xml_InternalError
Definition SR.cs:54
Definition SR.cs:7
override string ToString()
StringBuilder Append(char value, int repeatCount)
void ThrowInvalidChar(char[] data, int length, int invCharPos)
readonly StringBuilder _stringBuilder
async Task< string > ParseEntityNameAsync()
void AddAttributeChunkToList(NodeData attr, NodeData chunk, ref NodeData lastChunk)
async Task<(int, EntityType)> HandleEntityReferenceAsync(bool isInAttributeValue, EntityExpandType expandType)
bool HandleEntityEnd(bool checkEntityNesting)
void Throw(int pos, string res, string arg)

References System.Xml.XmlTextReaderImpl._fragmentType, System.Xml.XmlTextReaderImpl._fullAttrCleanup, System.Xml.XmlTextReaderImpl._normalize, System.Xml.XmlTextReaderImpl._parsingMode, System.Xml.XmlTextReaderImpl._ps, System.Xml.XmlTextReaderImpl._stringBuilder, System.Xml.XmlTextReaderImpl.AddAttributeChunkToList(), System.Text.StringBuilder.Append(), System.Xml.XmlException.BuildCharExceptionArgs(), System.ch, System.Xml.XmlTextReaderImpl.ParsingState.charPos, System.chars, System.Xml.XmlTextReaderImpl.ParsingState.chars, System.Xml.XmlTextReaderImpl.ParsingState.charsUsed, System.Xml.Dictionary, System.Xml.XmlTextReaderImpl.ParsingState.entity, System.Xml.XmlTextReaderImpl.ParsingState.entityId, System.Xml.XmlTextReaderImpl.ParsingState.eolNormalized, System.Xml.XmlTextReaderImpl.HandleEntityEnd(), System.Xml.XmlTextReaderImpl.HandleEntityReferenceAsync(), System.Xml.XmlTextReaderImpl.int, System.Xml.XmlCharType.IsAttributeValueChar(), System.Xml.XmlTextReaderImpl.ParsingState.isEof, System.Xml.XmlCharType.IsHighSurrogate(), System.Xml.XmlCharType.IsLowSurrogate(), System.Text.StringBuilder.Length, System.Xml.XmlTextReaderImpl.ParsingState.lineNo, System.Xml.XmlTextReaderImpl.ParsingState.LineNo, System.Xml.XmlTextReaderImpl.ParsingState.LinePos, System.Xml.IDtdEntityInfo.Name, System.Xml.XmlTextReaderImpl.OnNewLine(), System.Xml.XmlTextReaderImpl.ParseEntityNameAsync(), System.Xml.XmlTextReaderImpl.ReadDataAsync(), System.text, System.Xml.XmlTextReaderImpl.Throw(), System.Xml.XmlTextReaderImpl.ThrowInvalidChar(), System.Text.StringBuilder.ToString(), System.SR.Xml_BadAttributeChar, System.SR.Xml_EntityRefNesting, System.SR.Xml_InternalError, System.SR.Xml_UnclosedQuote, and System.SR.Xml_UnexpectedEOF1.

Referenced by System.Xml.XmlTextReaderImpl.ParseAttributesAsync().