/// <summary> /// Appends a specified number of copies of a shaped character to the end of the /// current <see cref="ShapedStringBuilder"/> instance. /// </summary> /// <param name="value">The value to append.</param> /// <param name="repeatCount">The number of times to append <paramref name="repeatCount"/>.</param> /// <returns>A reference to this instance after the append operation has completed.</returns> public ShapedStringBuilder Append(ShapedChar value, Int32 repeatCount) { for (int i = 0; i < repeatCount; i++) { Append(value); } return(this); }
/// <summary> /// Gets the index of the first occurrence of the specified character within the shaped string segment. /// </summary> /// <param name="value">The shaped character for which to search.</param> /// <returns>The index of the first occurrence of the specified shaped character, or -1 if the segment does not contain the shaped character.</returns> public Int32 IndexOf(ShapedChar value) { if (Source is IStringSource <ShapedChar> src) { for (int i = 0; i < Length; i++) { if (src[i] == value) { return(i); } } } return(-1); }
/// <summary> /// Creates the internal buffer for a <see cref="ShapedString"/> instance based on the specified input parameters. /// </summary> private static ShapedChar[] CreateShapedString(ShapedChar[] value, Int32 startIndex, Int32 count) { if (value == null) { throw new ArgumentNullException(nameof(value)); } if (startIndex < 0 || startIndex >= value.Length) { throw new ArgumentOutOfRangeException(nameof(startIndex)); } if (count < 0 || startIndex + count > value.Length) { throw new ArgumentOutOfRangeException(nameof(count)); } var buffer = new ShapedChar[count]; Array.Copy(value, startIndex, buffer, 0, count); return(buffer); }
/// <inheritdoc/> public void GetChar(Int32 index, out ShapedChar ch) { Contract.EnsureRange(index < Length, nameof(index)); ch = buffer[index]; }
/// <inheritdoc/> public void GetChar(Int32 index, out ShapedChar ch) => ch = buffer[index];
/// <summary> /// Appends a shaped character to the end of the current <see cref="ShapedStringBuilder"/> instance. /// </summary> /// <param name="value">The value to append.</param> /// <returns>A reference to this instance after the append operation has completed.</returns> public ShapedStringBuilder Append(ShapedChar value) { EnsureCapacity(length + 1); buffer[length++] = value; return(this); }
/// <inheritdoc/> public void GetChar(Int32 index, out ShapedChar ch) => ch = this[index];