예제 #1
0
        public TextToTextConverter(
            TextParser parser,
            TextOutput output,
            Injection injection,
            bool convertFragment,
            bool treatNbspAsBreakable,
            Stream traceStream,
            bool traceShowTokenNum,
            int traceStopOnTokenNum)
        {
#if DEBUG
            if (traceStream != null)
            {
                trace = new TestHtmlTrace(traceStream, traceShowTokenNum, traceStopOnTokenNum);
            }
#endif
            this.treatNbspAsBreakable = treatNbspAsBreakable;

            this.convertFragment = convertFragment;

            this.output = output;
            this.parser = parser;

            if (!this.convertFragment)
            {
                this.injection = injection;
            }
        }
예제 #2
0
 // Token: 0x060019C9 RID: 6601 RVA: 0x000CC89C File Offset: 0x000CAA9C
 public TextToTextConverter(TextParser parser, TextOutput output, Injection injection, bool convertFragment, bool treatNbspAsBreakable, Stream traceStream, bool traceShowTokenNum, int traceStopOnTokenNum)
 {
     this.treatNbspAsBreakable = treatNbspAsBreakable;
     this.convertFragment      = convertFragment;
     this.output    = output;
     this.parser    = parser;
     this.injection = injection;
 }
예제 #3
0
        void IDisposable.Dispose()
        {
            if (parser != null /*&& this.parser is IDisposable*/)
            {
                ((IDisposable)parser).Dispose();
            }

            if (!convertFragment && output != null && output is IDisposable)
            {
                ((IDisposable)output).Dispose();
            }
            parser = null;
            output = null;
            GC.SuppressFinalize(this);
        }
예제 #4
0
        void IDisposable.Dispose()
        {
            if (parser != null /*&& this.parser is IDisposable*/)
            {
                ((IDisposable)parser).Dispose();
            }

            if (!convertFragment && output != null && output is IDisposable)
            {
                ((IDisposable)output).Dispose();
            }
#if DEBUG
            if (trace != null /*&& this.trace is IDisposable*/)
            {
                ((IDisposable)trace).Dispose();
            }
#endif
            parser = null;
            output = null;
#if DEBUG
            trace = null;
#endif
            GC.SuppressFinalize(this);
        }
예제 #5
0
		// Token: 0x060019F5 RID: 6645 RVA: 0x000CD8CC File Offset: 0x000CBACC
		bool IFallback.FallBackChar(char ch, char[] outputBuffer, ref int outputBufferCount, int outputEnd)
		{
			if (this.htmlEscape)
			{
				HtmlEntityIndex htmlEntityIndex = (HtmlEntityIndex)0;
				if (ch <= '>')
				{
					if (ch == '>')
					{
						htmlEntityIndex = HtmlEntityIndex.gt;
					}
					else if (ch == '<')
					{
						htmlEntityIndex = HtmlEntityIndex.lt;
					}
					else if (ch == '&')
					{
						htmlEntityIndex = HtmlEntityIndex.amp;
					}
					else if (ch == '"')
					{
						htmlEntityIndex = HtmlEntityIndex.quot;
					}
				}
				else if ('\u00a0' <= ch && ch <= 'ÿ')
				{
					htmlEntityIndex = HtmlSupport.EntityMap[(int)(ch - '\u00a0')];
				}
				if (htmlEntityIndex != (HtmlEntityIndex)0)
				{
					string name = HtmlNameData.entities[(int)htmlEntityIndex].Name;
					if (outputEnd - outputBufferCount < name.Length + 2)
					{
						return false;
					}
					outputBuffer[outputBufferCount++] = '&';
					name.CopyTo(0, outputBuffer, outputBufferCount, name.Length);
					outputBufferCount += name.Length;
					outputBuffer[outputBufferCount++] = ';';
				}
				else
				{
					uint num = (uint)ch;
					int num2 = (num < 16U) ? 1 : ((num < 256U) ? 2 : ((num < 4096U) ? 3 : 4));
					if (outputEnd - outputBufferCount < num2 + 4)
					{
						return false;
					}
					outputBuffer[outputBufferCount++] = '&';
					outputBuffer[outputBufferCount++] = '#';
					outputBuffer[outputBufferCount++] = 'x';
					int num3 = outputBufferCount + num2;
					while (num != 0U)
					{
						uint num4 = num & 15U;
						outputBuffer[--num3] = (char)((ulong)num4 + (ulong)((num4 < 10U) ? 48L : 55L));
						num >>= 4;
					}
					outputBufferCount += num2;
					outputBuffer[outputBufferCount++] = ';';
				}
			}
			else
			{
				string substitute = TextOutput.GetSubstitute(ch);
				if (substitute != null)
				{
					if (outputEnd - outputBufferCount < substitute.Length)
					{
						return false;
					}
					substitute.CopyTo(0, outputBuffer, outputBufferCount, substitute.Length);
					outputBufferCount += substitute.Length;
				}
				else
				{
					outputBuffer[outputBufferCount++] = ch;
				}
			}
			return true;
		}