Exemple #1
0
        /// <summary>
        /// Gets or sets the symbol at the specified index.
        /// </summary>
        /// <param name="index">The zero-based index of the symbol to get or set.</param>
        /// <returns> The symbol at the specified index.</returns>
        public ISequenceItem this[int index]
        {
            get
            {
                int position = index;
                if (_editedSequences != null && _editedSequences.Values.Count > 0)
                {
                    CacheBox <IDerivedSequence> editedBlock = GetEditedBlock(position);
                    if (editedBlock != null)
                    {
                        IDerivedSequence derivedSeq = editedBlock.Data;
                        return(derivedSeq[position - (int)editedBlock.StartRange]);
                    }
                    else
                    {
                        position = position + (int)GetPositionDiff(position);
                    }
                }

                CacheBox <Sequence> block = GetCacheBlock(position);
                if (block != null)
                {
                    return(block.Data[position - (int)block.StartRange]);
                }
                else
                {
                    return(null);
                }
            }

            set
            {
                if (value == null)
                {
                    throw new ArgumentNullException("value");
                }
                if (IsReadOnly)
                {
                    throw new InvalidOperationException(Properties.Resource.CanNotModifyReadonlySequence);
                }
                // Sequence edit is not taken care when DV is enabled.
            }
        }
Exemple #2
0
        /// <summary>
        /// Gets or sets the symbol at the specified index.
        /// </summary>
        /// <param name="index">The zero-based index of the symbol to get or set.</param>
        /// <returns> The symbol at the specified index.</returns>
        public byte this[int index]
        {
            get
            {
                int position = index;
                if (_editedSequences != null && _editedSequences.Values.Count > 0)
                {
                    CacheBox <IDerivedSequence> editedBlock = GetEditedBlock(position);
                    if (editedBlock != null)
                    {
                        IDerivedSequence derivedSeq = editedBlock.Data;
                        return((byte)derivedSeq[position - (int)editedBlock.StartRange].Symbol);
                    }
                    else
                    {
                        position = position + (int)GetPositionDiff(position);
                    }
                }

                CacheBox <byte[]> block = GetCacheBlock(position);
                if (block != null)
                {
                    return(block.Data[position - (int)block.StartRange]);
                }
                else
                {
                    return(default(byte));
                }
            }

            set
            {
                if (IsReadOnly)
                {
                    throw new InvalidOperationException(Properties.Resource.CanNotModifyReadonlySequence);
                }
                Replace(index, value);
            }
        }