private void Parse()
        {
            this._state           = MixedCodeDocument.ParseState.Text;
            this._index           = 0;
            this._currentfragment = this.CreateFragment(MixedCodeDocumentFragmentType.Text);
            while (this._index < this._text.Length)
            {
                this._c = (int)this._text[this._index];
                this.IncrementPosition();
                switch (this._state)
                {
                case MixedCodeDocument.ParseState.Text:
                    if (this._index + this.TokenCodeStart.Length < this._text.Length && this._text.Substring(this._index - 1, this.TokenCodeStart.Length) == this.TokenCodeStart)
                    {
                        this._state = MixedCodeDocument.ParseState.Code;
                        this._currentfragment.Length = this._index - 1 - this._currentfragment.Index;
                        this._currentfragment        = this.CreateFragment(MixedCodeDocumentFragmentType.Code);
                        this.SetPosition();
                    }
                    break;

                case MixedCodeDocument.ParseState.Code:
                    if (this._index + this.TokenCodeEnd.Length < this._text.Length && this._text.Substring(this._index - 1, this.TokenCodeEnd.Length) == this.TokenCodeEnd)
                    {
                        this._state = MixedCodeDocument.ParseState.Text;
                        this._currentfragment.Length = this._index + this.TokenCodeEnd.Length - this._currentfragment.Index;
                        this._index          += this.TokenCodeEnd.Length;
                        this._lineposition   += this.TokenCodeEnd.Length;
                        this._currentfragment = this.CreateFragment(MixedCodeDocumentFragmentType.Text);
                        this.SetPosition();
                    }
                    break;
                }
            }
            this._currentfragment.Length = this._index - this._currentfragment.Index;
        }
 private void Parse()
 {
   this._state = MixedCodeDocument.ParseState.Text;
   this._index = 0;
   this._currentfragment = this.CreateFragment(MixedCodeDocumentFragmentType.Text);
   while (this._index < this._text.Length)
   {
     this._c = (int) this._text[this._index];
     this.IncrementPosition();
     switch (this._state)
     {
       case MixedCodeDocument.ParseState.Text:
         if (this._index + this.TokenCodeStart.Length < this._text.Length && this._text.Substring(this._index - 1, this.TokenCodeStart.Length) == this.TokenCodeStart)
         {
           this._state = MixedCodeDocument.ParseState.Code;
           this._currentfragment.Length = this._index - 1 - this._currentfragment.Index;
           this._currentfragment = this.CreateFragment(MixedCodeDocumentFragmentType.Code);
           this.SetPosition();
           continue;
         }
         continue;
       case MixedCodeDocument.ParseState.Code:
         if (this._index + this.TokenCodeEnd.Length < this._text.Length && this._text.Substring(this._index - 1, this.TokenCodeEnd.Length) == this.TokenCodeEnd)
         {
           this._state = MixedCodeDocument.ParseState.Text;
           this._currentfragment.Length = this._index + this.TokenCodeEnd.Length - this._currentfragment.Index;
           this._index += this.TokenCodeEnd.Length;
           this._lineposition += this.TokenCodeEnd.Length;
           this._currentfragment = this.CreateFragment(MixedCodeDocumentFragmentType.Text);
           this.SetPosition();
           continue;
         }
         continue;
       default:
         continue;
     }
   }
   this._currentfragment.Length = this._index - this._currentfragment.Index;
 }