/// <summary> /// Appends the contents of the specified string source at the end of the string builder. /// </summary> /// <param name="value">The value to append.</param> /// <returns>The current instance of <see cref="VersionedStringBuilder"/>.</returns> public VersionedStringBuilder Append(VersionedStringSource value) { if (value.IsValid) { if (value.IsSourcedFromString) { Append((String)value); } else { Append((VersionedStringBuilder)value); } } return(this); }
/// <summary> /// Inserts the contents of the specified string source at the specified index within the string builder. /// </summary> /// <param name="index">The index at which to insert the value.</param> /// <param name="value">The value to insert.</param> /// <returns>The current instance of <see cref="VersionedStringBuilder"/>.</returns> public VersionedStringBuilder Insert(Int32 index, VersionedStringSource value) { if (value.IsValid) { if (value.IsSourcedFromString) { Insert(index, (String)value); } else { Insert(index, (VersionedStringBuilder)value); } } else { if (index < 0 || index > stringBuilder.Length) { throw new ArgumentOutOfRangeException("index"); } } return(this); }
/// <summary> /// Appends the contents of a <see cref="VersionedStringSource"/> to the end of the string builder. /// </summary> /// <param name="this">The <see cref="StringBuilder"/> instance.</param> /// <param name="value">The <see cref="VersionedStringSource"/> to append to the string builder.</param> /// <returns>The current <see cref="StringBuilder"/> instance.</returns> public static StringBuilder AppendVersionedStringSource(this StringBuilder @this, VersionedStringSource value) { Contract.Require(@this, "this"); if (value.IsValid) { if (value.IsSourcedFromString) { var source = (String)value; @this.Append(source); } else { var source = (VersionedStringBuilder)value; for (int i = 0; i < source.Length; i++) { @this.Append(source[i]); } } } return(@this); }
/// <summary> /// Inserts the contents of a <see cref="VersionedStringSource"/> into the string builder at the specified position. /// </summary> /// <param name="this">The <see cref="StringBuilder"/> instance.</param> /// <param name="index">The index at which to begin inserting the value.</param> /// <param name="value">The <see cref="VersionedStringSource"/> to insert into the string builder.</param> /// <returns>The current <see cref="StringBuilder"/> instance.</returns> public static StringBuilder InsertVersionedStringSource(this StringBuilder @this, Int32 index, VersionedStringSource value) { Contract.Require(@this, "this"); Contract.EnsureRange(index >= 0 && index <= @this.Length, nameof(index)); if (value.IsValid) { if (value.IsSourcedFromString) { var source = (String)value; @this.Insert(index, source); } else { var source = (VersionedStringBuilder)value; for (int i = 0; i < source.Length; i++) { @this.Insert(index + i, source[i]); } } } return(@this); }
/// <summary> /// Performs a pass-through conversion for an instance of the <see cref="VersionedStringSource"/> structure. /// </summary> /// <param name="value">The string to convert.</param> /// <param name="example">An example value which will cause the compiler to perform type inference.</param> /// <returns>The value that was created.</returns> protected VersionedStringSource __UPF_ConvertFromString(VersionedStringSource value, VersionedStringSource example) { return(value); }