/// <summary>
 /// Appends a fragment to the list of fragments.
 /// </summary>
 /// <param name="newFragment">The fragment to append. May not be null.</param>
 public void Append(MixedCodeDocumentFragment newFragment)
 {
     if (newFragment == null)
     {
         throw new ArgumentNullException("newFragment");
     }
     _items.Add(newFragment);
 }
Beispiel #2
0
 public void Append(MixedCodeDocumentFragment newFragment)
 {
     if (newFragment == null)
     {
         throw new ArgumentNullException(nameof(newFragment));
     }
     this._items.Add(newFragment);
 }
Beispiel #3
0
 /// <summary>
 /// Appends a fragment to the list of fragments.
 /// </summary>
 /// <param name="newFragment">The fragment to append. May not be null.</param>
 public void Append(MixedCodeDocumentFragment newFragment)
 {
     if (newFragment == null)
     {
         throw new ArgumentNullException("newFragment");
     }
     _items.Add(newFragment);
 }
 /// <summary>
 /// Prepends a fragment to the list of fragments.
 /// </summary>
 /// <param name="newFragment">The fragment to append. May not be null.</param>
 public void Prepend(MixedCodeDocumentFragment newFragment)
 {
     if (newFragment == null)
     {
         throw new ArgumentNullException("newFragment");
     }
     _items.Insert(0, newFragment);
 }
Beispiel #5
0
 /// <summary>
 /// Prepends a fragment to the list of fragments.
 /// </summary>
 /// <param name="newFragment">The fragment to append. May not be null.</param>
 public void Prepend(MixedCodeDocumentFragment newFragment)
 {
     if (newFragment == null)
     {
         throw new ArgumentNullException("newFragment");
     }
     _items.Insert(0, newFragment);
 }
 /// <summary>
 /// Remove a fragment from the list of fragments. If this fragment was not in the list, an exception will be raised.
 /// </summary>
 /// <param name="fragment">The fragment to remove. May not be null.</param>
 public void Remove(MixedCodeDocumentFragment fragment)
 {
     if (fragment == null)
     {
         throw new ArgumentNullException("fragment");
     }
     int index = GetFragmentIndex(fragment);
     if (index == -1)
     {
         throw new IndexOutOfRangeException();
     }
     RemoveAt(index);
 }
Beispiel #7
0
        /// <summary>
        /// Remove a fragment from the list of fragments. If this fragment was not in the list, an exception will be raised.
        /// </summary>
        /// <param name="fragment">The fragment to remove. May not be null.</param>
        public void Remove(MixedCodeDocumentFragment fragment)
        {
            if (fragment == null)
            {
                throw new ArgumentNullException("fragment");
            }
            int index = GetFragmentIndex(fragment);

            if (index == -1)
            {
                throw new IndexOutOfRangeException();
            }
            RemoveAt(index);
        }
Beispiel #8
0
        public void Remove(MixedCodeDocumentFragment fragment)
        {
            if (fragment == null)
            {
                throw new ArgumentNullException(nameof(fragment));
            }
            int fragmentIndex = this.GetFragmentIndex(fragment);

            if (fragmentIndex == -1)
            {
                throw new IndexOutOfRangeException();
            }
            this.RemoveAt(fragmentIndex);
        }
Beispiel #9
0
        private void Parse()
        {
            _state           = ParseState.Text;
            _index           = 0;
            _currentfragment = CreateFragment(MixedCodeDocumentFragmentType.Text);

            while (_index < _text.Length)
            {
                _c = _text[_index];
                IncrementPosition();

                switch (_state)
                {
                case ParseState.Text:
                    if (_index + TokenCodeStart.Length < _text.Length)
                    {
                        if (_text.Substring(_index - 1, TokenCodeStart.Length) == TokenCodeStart)
                        {
                            _state = ParseState.Code;
                            _currentfragment.Length = _index - 1 - _currentfragment.Index;
                            _currentfragment        = CreateFragment(MixedCodeDocumentFragmentType.Code);
                            SetPosition();
                            continue;
                        }
                    }

                    break;

                case ParseState.Code:
                    if (_index + TokenCodeEnd.Length < _text.Length)
                    {
                        if (_text.Substring(_index - 1, TokenCodeEnd.Length) == TokenCodeEnd)
                        {
                            _state = ParseState.Text;
                            _currentfragment.Length = _index + TokenCodeEnd.Length - _currentfragment.Index;
                            _index          += TokenCodeEnd.Length;
                            _lineposition   += TokenCodeEnd.Length;
                            _currentfragment = CreateFragment(MixedCodeDocumentFragmentType.Text);
                            SetPosition();
                            continue;
                        }
                    }

                    break;
                }
            }

            _currentfragment.Length = _index - _currentfragment.Index;
        }
Beispiel #10
0
 internal int GetFragmentIndex(MixedCodeDocumentFragment fragment)
 {
     if (fragment == null)
     {
         throw new ArgumentNullException("fragment");
     }
     for (int i = 0; i < _items.Count; i++)
     {
         if ((_items[i]) == fragment)
         {
             return(i);
         }
     }
     return(-1);
 }
Beispiel #11
0
        internal int GetFragmentIndex(MixedCodeDocumentFragment fragment)
        {
            if (fragment == null)
            {
                throw new ArgumentNullException(nameof(fragment));
            }
            for (int index = 0; index < this._items.Count; ++index)
            {
                if (this._items[index] == fragment)
                {
                    return(index);
                }
            }

            return(-1);
        }
Beispiel #12
0
        private void Parse()
        {
            this._state           = 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 ParseState.Text:
                    if (this._index + this.TokenCodeStart.Length < this._text.Length &&
                        this._text.Substring(this._index - 1, this.TokenCodeStart.Length) == this.TokenCodeStart)
                    {
                        this._state = ParseState.Code;
                        this._currentfragment.Length = this._index - 1 - this._currentfragment.Index;
                        this._currentfragment        = this.CreateFragment(MixedCodeDocumentFragmentType.Code);
                        this.SetPosition();
                        continue;
                    }

                    continue;

                case ParseState.Code:
                    if (this._index + this.TokenCodeEnd.Length < this._text.Length &&
                        this._text.Substring(this._index - 1, this.TokenCodeEnd.Length) == this.TokenCodeEnd)
                    {
                        this._state = 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;
        }
 internal int GetFragmentIndex(MixedCodeDocumentFragment fragment)
 {
     if (fragment == null)
     {
         throw new ArgumentNullException("fragment");
     }
     for (int i = 0; i < _items.Count; i++)
     {
         if (((MixedCodeDocumentFragment)_items[i]) == fragment)
         {
             return i;
         }
     }
     return -1;
 }
        private void Parse()
        {
            _state = ParseState.Text;
            _index = 0;
            _currentfragment = CreateFragment(MixedCodeDocumentFragmentType.Text);

            while (_index < _text.Length)
            {
                _c = _text[_index];
                IncrementPosition();

                switch (_state)
                {
                    case ParseState.Text:
                        if (_index + TokenCodeStart.Length < _text.Length)
                        {
                            if (_text.Substring(_index - 1, TokenCodeStart.Length) == TokenCodeStart)
                            {
                                _state = ParseState.Code;
                                _currentfragment.Length = _index - 1 - _currentfragment.Index;
                                _currentfragment = CreateFragment(MixedCodeDocumentFragmentType.Code);
                                SetPosition();
                                continue;
                            }
                        }
                        break;

                    case ParseState.Code:
                        if (_index + TokenCodeEnd.Length < _text.Length)
                        {
                            if (_text.Substring(_index - 1, TokenCodeEnd.Length) == TokenCodeEnd)
                            {
                                _state = ParseState.Text;
                                _currentfragment.Length = _index + TokenCodeEnd.Length - _currentfragment.Index;
                                _index += TokenCodeEnd.Length;
                                _lineposition += TokenCodeEnd.Length;
                                _currentfragment = CreateFragment(MixedCodeDocumentFragmentType.Text);
                                SetPosition();
                                continue;
                            }
                        }
                        break;
                }
            }

            _currentfragment.Length = _index - _currentfragment.Index;
        }
Beispiel #15
0
        /// <summary>
        /// Remove a fragment from the list of fragments, using its index in the list.
        /// </summary>
        /// <param name="index">The index of the fragment to remove.</param>
        public void RemoveAt(int index)
        {
            MixedCodeDocumentFragment frag = (MixedCodeDocumentFragment)_items[index];

            _items.RemoveAt(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;
 }
 internal int GetFragmentIndex(MixedCodeDocumentFragment fragment)
 {
   if (fragment == null)
     throw new ArgumentNullException("fragment");
   for (int index = 0; index < this._items.Count; ++index)
   {
     if (this._items[index] == fragment)
       return index;
   }
   return -1;
 }
 /// <summary>
 /// Remove a fragment from the list of fragments. If this fragment was not in the list, an exception will be raised.
 /// 
 /// </summary>
 /// <param name="fragment">The fragment to remove. May not be null.</param>
 public void Remove(MixedCodeDocumentFragment fragment)
 {
   if (fragment == null)
     throw new ArgumentNullException("fragment");
   int fragmentIndex = this.GetFragmentIndex(fragment);
   if (fragmentIndex == -1)
     throw new IndexOutOfRangeException();
   this.RemoveAt(fragmentIndex);
 }