Exemplo n.º 1
0
 // Token: 0x060060E3 RID: 24803 RVA: 0x0014A728 File Offset: 0x00148928
 public void Append(StringBuffer value, uint startIndex, uint count)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     if (count == 0U)
     {
         return;
     }
     value.CopyTo(startIndex, this, this._length, count);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Append the given buffer.
        /// </summary>
        /// <param name="value">The buffer to append.</param>
        /// <param name="startIndex">The index in the input buffer to start appending from.</param>
        /// <param name="count">The count of characters to copy from the buffer string.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="value"/> is null.</exception>
        /// <exception cref="ArgumentOutOfRangeException">
        /// Thrown if <paramref name="startIndex"/> or <paramref name="count"/> are outside the range
        /// of <paramref name="value"/> characters.
        /// </exception>
        public void Append(ref StringBuffer value, int startIndex, int count)
        {
            if (count == 0)
            {
                return;
            }

            value.CopyTo(
                bufferIndex: startIndex,
                destination: ref this,
                destinationIndex: _length,
                count: count);
        }
Exemplo n.º 3
0
        private static ulong GetInputBuffer(StringBuffer content, bool isUnc, out StringBuffer buffer)
        {
            ulong length = content.Length;
            length += isUnc ? (ulong)PathInternal.UncExtendedPrefixToInsert.Length : (ulong)PathInternal.ExtendedPathPrefix.Length;
            buffer = new StringBuffer(length);

            if (isUnc)
            {
                buffer.CopyFrom(bufferIndex: 0, source: PathInternal.UncExtendedPathPrefix);
                ulong prefixDifference = (ulong)(PathInternal.UncExtendedPathPrefix.Length - PathInternal.UncPathPrefix.Length);
                content.CopyTo(bufferIndex: prefixDifference, destination: buffer, destinationIndex: (ulong)PathInternal.ExtendedPathPrefix.Length, count: content.Length - prefixDifference);
                return prefixDifference;
            }
            else
            {
                ulong prefixSize = (ulong)PathInternal.ExtendedPathPrefix.Length;
                buffer.CopyFrom(bufferIndex: 0, source: PathInternal.ExtendedPathPrefix);
                content.CopyTo(bufferIndex: 0, destination: buffer, destinationIndex: prefixSize, count: content.Length);
                return prefixSize;
            }
        }
Exemplo n.º 4
0
        private static uint GetInputBuffer(StringBuffer content, bool isDosUnc, out StringBuffer buffer)
        {
            uint length = content.Length;

            length += isDosUnc
                ? (uint)PathInternal.UncExtendedPrefixLength - PathInternal.UncPrefixLength
                : PathInternal.DevicePrefixLength;

            buffer = new StringBuffer(length);

            if (isDosUnc)
            {
                // Put the extended UNC prefix (\\?\UNC\) in front of the path
                buffer.CopyFrom(bufferIndex: 0, source: PathInternal.UncExtendedPathPrefix);

                // Copy the source buffer over after the existing UNC prefix
                content.CopyTo(
                    bufferIndex: PathInternal.UncPrefixLength,
                    destination: buffer,
                    destinationIndex: PathInternal.UncExtendedPrefixLength,
                    count: content.Length - PathInternal.UncPrefixLength);

                // Return the prefix difference
                return (uint)PathInternal.UncExtendedPrefixLength - PathInternal.UncPrefixLength;
            }
            else
            {
                uint prefixSize = (uint)PathInternal.ExtendedPathPrefix.Length;
                buffer.CopyFrom(bufferIndex: 0, source: PathInternal.ExtendedPathPrefix);
                content.CopyTo(bufferIndex: 0, destination: buffer, destinationIndex: prefixSize, count: content.Length);
                return prefixSize;
            }
        }
Exemplo n.º 5
0
 public void CopyToBufferThrowsIndexingBeyondSourceBufferLength(string source, ulong index, ulong count)
 {
     using (var buffer = new StringBuffer(source))
     using (var targetBuffer = new StringBuffer())
     {
         Assert.Throws<ArgumentOutOfRangeException>(() => { buffer.CopyTo(index, targetBuffer, 0, count); });
     }
 }
Exemplo n.º 6
0
 public void CopyToBufferThrowsOnNull()
 {
     using (var buffer = new StringBuffer())
     {
         Assert.Throws<ArgumentNullException>(() => { buffer.CopyTo(0, null, 0, 0); });
     }
 }
Exemplo n.º 7
0
 public void CopyToBufferString(string destination, string content, ulong destinationIndex, ulong bufferIndex, ulong count, string expected)
 {
     using (var buffer = new StringBuffer(content))
     using (var destinationBuffer = new StringBuffer(destination))
     {
         buffer.CopyTo(bufferIndex, destinationBuffer, destinationIndex, count);
         Assert.Equal(expected, destinationBuffer.ToString());
     }
 }