1 // HtmlAgilityPack V1.0 - Simon Mourier <simon underscore mourier at hotmail dot com>
\r
2 namespace HtmlAgilityPack
\r
5 /// Represents a base class for fragments in a mixed code document.
\r
7 public abstract class MixedCodeDocumentFragment
\r
11 internal MixedCodeDocument Doc;
\r
12 private string _fragmentText;
\r
14 internal int Length;
\r
16 internal int _lineposition;
\r
17 internal MixedCodeDocumentFragmentType _type;
\r
21 #region Constructors
\r
23 internal MixedCodeDocumentFragment(MixedCodeDocument doc, MixedCodeDocumentFragmentType type)
\r
29 case MixedCodeDocumentFragmentType.Text:
\r
30 Doc._textfragments.Append(this);
\r
33 case MixedCodeDocumentFragmentType.Code:
\r
34 Doc._codefragments.Append(this);
\r
37 Doc._fragments.Append(this);
\r
45 /// Gets the fragement text.
\r
47 public string FragmentText
\r
51 if (_fragmentText == null)
\r
53 _fragmentText = Doc._text.Substring(Index, Length);
\r
55 return FragmentText;
\r
57 internal set { _fragmentText = value; }
\r
61 /// Gets the type of fragment.
\r
63 public MixedCodeDocumentFragmentType FragmentType
\r
65 get { return _type; }
\r
69 /// Gets the line number of the fragment.
\r
73 get { return _line; }
\r
74 internal set { _line = value; }
\r
78 /// Gets the line position (column) of the fragment.
\r
80 public int LinePosition
\r
82 get { return _lineposition; }
\r
86 /// Gets the fragment position in the document's stream.
\r
88 public int StreamPosition
\r
90 get { return Index; }
\r