Ejemplo n.º 1
0
        /// <summary>
        /// Gets or sets the text at given index. Once an element is set, it cannot be overwritten.
        /// </summary>
        /// <param name="index">Element index</param>
        /// <exception cref="InvalidOperationException">List is not initialized</exception>
        /// <exception cref="IndexOutOfRangeException"><paramref name="index"/> is out of range.</exception>
        /// <exception cref="ArgumentOutOfRangeException">UTF-8 encoding exceeds 2^29-2 bytes</exception>
        public string?this[int index]
        {
            get
            {
                ListSerializerHelper.EnsureAllocated(this);

                if (index < 0 || index >= Count)
                {
                    throw new IndexOutOfRangeException();
                }

                return(ReadText(index));
            }
            set
            {
                ListSerializerHelper.EnsureAllocated(this);

                if (index < 0 || index >= Count)
                {
                    throw new IndexOutOfRangeException();
                }

                WriteText(index, value);
            }
        }
Ejemplo n.º 2
0
        public T this[int index]
        {
            get
            {
                ListSerializerHelper.EnsureAllocated(this);

                try
                {
                    return((Rpc.CapabilityReflection.CreateProxy <T>(DecodeCapPointer(index)) as T) !);
                }
                catch (ArgumentOutOfRangeException)
                {
                    throw new IndexOutOfRangeException();
                }
            }
            set
            {
                ListSerializerHelper.EnsureAllocated(this);

                if (index < 0 || index >= RawData.Length)
                {
                    throw new IndexOutOfRangeException("index out of range");
                }

                var p = default(WirePointer);
                p.SetCapability(ProvideCapability(value));
                RawData[index] = p;
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Gets or sets the value at given index.
 /// </summary>
 /// <param name="index">Element index</param>
 /// <returns>Element value</returns>
 public T this[int index]
 {
     get
     {
         ListSerializerHelper.EnsureAllocated(this);
         return(Data[index]);
     }
     set
     {
         ListSerializerHelper.EnsureAllocated(this);
         Data[index] = value;
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets or sets the element at given index.
        /// </summary>
        /// <param name="index">Element index</param>
        /// <returns>Element value</returns>
        /// <exception cref="InvalidOperationException">List was not initialized, or attempting to overwrite a non-null element.</exception>
        /// <exception cref="IndexOutOfRangeException"><paramref name="index"/> is out of range.</exception>
        public bool this[int index]
        {
            get
            {
                ListSerializerHelper.EnsureAllocated(this);

                if (index < 0 || index >= Count)
                {
                    throw new IndexOutOfRangeException();
                }

                int wi = index / 64;
                int bi = index % 64;

                return(((RawData[wi] >> bi) & 1) != 0);
            }
            set
            {
                ListSerializerHelper.EnsureAllocated(this);

                if (index < 0 || index >= Count)
                {
                    throw new IndexOutOfRangeException();
                }

                int wi = index / 64;
                int bi = index % 64;

                if (value)
                {
                    RawData[wi] |= (1ul << bi);
                }
                else
                {
                    RawData[wi] &= ~(1ul << bi);
                }
            }
        }