📄 entity.cs
字号:
public char ReadChar()
{
char ch1 = (char) ((ushort) this.stm.Read());
if (ch1 == '\0')
{
ch1 = ' ';
}
this.absolutePos++;
if (ch1 == '\n')
{
this.IsWhitespace = true;
this.lineStart = this.absolutePos + 1;
this.Line++;
}
else if ((ch1 == ' ') || (ch1 == '\t'))
{
this.IsWhitespace = true;
if (this.Lastchar == '\r')
{
this.lineStart = this.absolutePos;
this.Line++;
}
}
else if (ch1 == '\r')
{
this.IsWhitespace = true;
}
else
{
this.IsWhitespace = false;
if (this.Lastchar == '\r')
{
this.Line++;
this.lineStart = this.absolutePos;
}
}
this.Lastchar = ch1;
return ch1;
}
public string ScanLiteral(StringBuilder sb, char quote)
{
sb.Length = 0;
for (char ch1 = this.ReadChar(); (ch1 != 0xffff) && (ch1 != quote); ch1 = this.ReadChar())
{
if (ch1 == '&')
{
ch1 = this.ReadChar();
if (ch1 == '#')
{
string text1 = this.ExpandCharEntity();
sb.Append(text1);
}
else
{
sb.Append('&');
sb.Append(ch1);
}
}
else
{
sb.Append(ch1);
}
}
this.ReadChar();
return sb.ToString();
}
public string ScanToEnd(StringBuilder sb, string type, string terminators)
{
if (sb != null)
{
sb.Length = 0;
}
int num1 = this.Line;
char ch1 = this.ReadChar();
int num2 = 0;
char ch2 = terminators[num2];
while (ch1 != 0xffff)
{
if (ch1 == ch2)
{
num2++;
if (num2 >= terminators.Length)
{
break;
}
ch2 = terminators[num2];
}
else if (num2 > 0)
{
int num3 = num2 - 1;
int num4 = 0;
while ((num3 >= 0) && (num4 == 0))
{
if (terminators[num3] == ch1)
{
int num5 = 1;
while ((num3 - num5) >= 0)
{
if (terminators[num3 - num5] != terminators[num2 - num5])
{
break;
}
num5++;
}
if (num5 > num3)
{
num4 = num3 + 1;
}
}
else
{
num3--;
}
}
if (sb != null)
{
num3 = (num3 < 0) ? 1 : 0;
for (int num6 = 0; num6 <= ((num2 - num4) - num3); num6++)
{
sb.Append(terminators[num6]);
}
if (num3 > 0)
{
sb.Append(ch1);
}
}
num2 = num4;
ch2 = terminators[num4];
}
else if (sb != null)
{
sb.Append(ch1);
}
ch1 = this.ReadChar();
}
if (ch1 == '\0')
{
this.Error(type + " starting on line {0} was never closed", num1);
}
this.ReadChar();
if (sb != null)
{
return sb.ToString();
}
return "";
}
public string ScanToken(StringBuilder sb, string term, bool nmtoken)
{
sb.Length = 0;
char ch1 = this.Lastchar;
if (!((!nmtoken || (ch1 == '_')) || char.IsLetter(ch1)))
{
throw new Exception(string.Format("Invalid name start character '{0}'", ch1));
}
while ((ch1 != 0xffff) && (term.IndexOf(ch1) < 0))
{
if ((((nmtoken && (ch1 != '_')) && ((ch1 != '.') && (ch1 != '-'))) && (ch1 != ':')) && !char.IsLetterOrDigit(ch1))
{
throw new Exception(string.Format("Invalid name character '{0}'", ch1));
}
sb.Append(ch1);
ch1 = this.ReadChar();
}
return sb.ToString();
}
public void SetLiteralType(string token)
{
switch (token)
{
case "CDATA":
this.LiteralType = FreeTextBoxControls.Support.Sgml.LiteralType.CDATA;
break;
case "SDATA":
this.LiteralType = FreeTextBoxControls.Support.Sgml.LiteralType.SDATA;
break;
case "PI":
this.LiteralType = FreeTextBoxControls.Support.Sgml.LiteralType.PI;
break;
}
}
public char SkipWhitespace()
{
char ch1 = this.Lastchar;
while ((ch1 != 0xffff) && ((((ch1 == ' ') || (ch1 == '\r')) || (ch1 == '\n')) || (ch1 == '\t')))
{
ch1 = this.ReadChar();
}
return ch1;
}
public int LinePosition
{
get
{
return ((this.absolutePos - this.lineStart) + 1);
}
}
public System.Uri ResolvedUri
{
get
{
if (this.resolvedUri != null)
{
return this.resolvedUri;
}
if (this.Parent != null)
{
return this.Parent.ResolvedUri;
}
return null;
}
}
private int absolutePos;
private static int[] CtrlMap;
private Encoding encoding;
public const char EOF = '\uffff';
public bool Html;
public bool Internal;
public bool IsWhitespace;
public char Lastchar;
public int Line;
private int lineStart;
public string Literal;
public FreeTextBoxControls.Support.Sgml.LiteralType LiteralType;
public string Name;
public Entity Parent;
public string Proxy;
public string PublicId;
private System.Uri resolvedUri;
private TextReader stm;
public string Uri;
private bool weOwnTheStream;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -