コード例 #1
0
        /// <summary>
        /// Rents a character array from the pool.
        /// </summary>
        /// <param name="bufferPool">The character pool.</param>
        /// <param name="minSize">The min required size of the character array.</param>
        /// <returns>The character array from the pool.</returns>
        public static char[] RentFromBuffer(ICharArrayPool bufferPool, int minSize)
        {
            if (bufferPool == null)
            {
                return(new char[minSize]);
            }

            char[] buffer = bufferPool.Rent(minSize);
            return(buffer);
        }
コード例 #2
0
        /// <summary>
        /// Rents a character array from the pool.
        /// </summary>
        /// <param name="bufferPool">The character pool.</param>
        /// <param name="minSize">The min required size of the character array.</param>
        /// <returns>The character array from the pool.</returns>
        public static char[] RentFromBuffer(ICharArrayPool bufferPool, int minSize)
        {
            if (bufferPool == null)
            {
                return(new char[minSize]);
            }

            char[] buffer = bufferPool.Rent(minSize);
            if (buffer == null || buffer.Length < minSize)
            {
                throw new ODataException(Strings.BufferUtils_InvalidBufferOrSize(minSize));
            }

            return(buffer);
        }