13 [__DynamicallyInvokable]
16 internal char[] m_ChunkChars;
20 internal int m_ChunkLength;
22 internal int m_ChunkOffset;
24 internal int m_MaxCapacity;
26 internal const int DefaultCapacity = 16;
28 private const string CapacityField =
"Capacity";
30 private const string MaxCapacityField =
"m_MaxCapacity";
32 private const string StringValueField =
"m_StringValue";
34 private const string ThreadIDField =
"m_currentThread";
36 internal const int MaxChunkSize = 8000;
41 [__DynamicallyInvokable]
44 [__DynamicallyInvokable]
47 return m_ChunkChars.Length + m_ChunkOffset;
49 [__DynamicallyInvokable]
66 int num = value - m_ChunkOffset;
67 char[] array =
new char[num];
68 Array.
Copy(m_ChunkChars, array, m_ChunkLength);
76 [__DynamicallyInvokable]
79 [__DynamicallyInvokable]
89 [__DynamicallyInvokable]
92 [__DynamicallyInvokable]
95 return m_ChunkOffset + m_ChunkLength;
97 [__DynamicallyInvokable]
109 if (value == 0 && m_ChunkPrevious ==
null)
122 if (stringBuilder !=
this)
124 int num2 = capacity - stringBuilder.m_ChunkOffset;
125 char[] array =
new char[num2];
126 Array.
Copy(stringBuilder.m_ChunkChars, array, stringBuilder.m_ChunkLength);
127 m_ChunkChars = array;
128 m_ChunkPrevious = stringBuilder.m_ChunkPrevious;
129 m_ChunkOffset = stringBuilder.m_ChunkOffset;
131 m_ChunkLength = value - stringBuilder.m_ChunkOffset;
142 [IndexerName(
"Chars")]
143 [__DynamicallyInvokable]
144 public char this[
int index]
146 [__DynamicallyInvokable]
152 int num = index - stringBuilder.m_ChunkOffset;
155 if (num >= stringBuilder.m_ChunkLength)
159 return stringBuilder.m_ChunkChars[num];
161 stringBuilder = stringBuilder.m_ChunkPrevious;
163 while (stringBuilder !=
null);
166 [__DynamicallyInvokable]
172 int num = index - stringBuilder.m_ChunkOffset;
175 if (num >= stringBuilder.m_ChunkLength)
179 stringBuilder.m_ChunkChars[num] = value;
182 stringBuilder = stringBuilder.m_ChunkPrevious;
184 while (stringBuilder !=
null);
190 [__DynamicallyInvokable]
200 [__DynamicallyInvokable]
202 : this(string.Empty, capacity)
208 [__DynamicallyInvokable]
219 [__DynamicallyInvokable]
221 : this(value, 0, value?.
Length ?? 0, capacity)
233 [SecuritySafeCritical]
234 [__DynamicallyInvokable]
235 public unsafe
StringBuilder(
string value,
int startIndex,
int length,
int capacity)
251 value =
string.Empty;
253 if (startIndex > value.Length - length)
257 m_MaxCapacity =
int.MaxValue;
262 if (capacity < length)
266 m_ChunkChars =
new char[capacity];
267 m_ChunkLength = length;
268 fixed (
char* ptr = value)
270 ThreadSafeCopy(ptr + startIndex, m_ChunkChars, 0, length);
279 [__DynamicallyInvokable]
282 if (capacity > maxCapacity)
296 capacity =
Math.
Min(16, maxCapacity);
298 m_MaxCapacity = maxCapacity;
299 m_ChunkChars =
new char[capacity];
311 int num2 =
int.MaxValue;
316 switch (enumerator.
Name)
318 case "m_MaxCapacity":
319 num2 = info.GetInt32(
"m_MaxCapacity");
321 case "m_StringValue":
322 text = info.GetString(
"m_StringValue");
325 num = info.GetInt32(
"Capacity");
334 if (num2 < 1 || text.Length > num2)
336 throw new SerializationException(Environment.GetResourceString(
"Serialization_StringBuilderMaxCapacity"));
341 if (num < text.Length)
350 if (num < 0 || num < text.Length || num > num2)
354 m_MaxCapacity = num2;
355 m_ChunkChars =
new char[num];
356 text.CopyTo(0, m_ChunkChars, 0, text.Length);
357 m_ChunkLength = text.Length;
358 m_ChunkPrevious =
null;
371 throw new ArgumentNullException(
"info");
373 info.AddValue(
"m_MaxCapacity", m_MaxCapacity);
374 info.AddValue(
"Capacity",
Capacity);
375 info.AddValue(
"m_StringValue",
ToString());
376 info.AddValue(
"m_currentThread", 0);
380 private void VerifyClassInvariant()
383 int maxCapacity = m_MaxCapacity;
387 if (chunkPrevious !=
null)
389 stringBuilder = chunkPrevious;
401 [__DynamicallyInvokable]
417 [SecuritySafeCritical]
418 [__DynamicallyInvokable]
425 string text =
string.FastAllocateString(
Length);
427 fixed (
char* ptr = text)
431 if (stringBuilder.m_ChunkLength > 0)
433 char[] chunkChars = stringBuilder.m_ChunkChars;
434 int chunkOffset = stringBuilder.m_ChunkOffset;
435 int chunkLength = stringBuilder.m_ChunkLength;
436 if ((uint)(chunkLength + chunkOffset) > text.Length || (uint)chunkLength > (uint)chunkChars.Length)
440 char[] array = chunkChars;
441 fixed (
char* smem = array)
443 string.wstrcpy(ptr + chunkOffset, smem, chunkLength);
446 stringBuilder = stringBuilder.m_ChunkPrevious;
448 while (stringBuilder !=
null);
459 [SecuritySafeCritical]
460 [__DynamicallyInvokable]
461 public unsafe
string ToString(
int startIndex,
int length)
468 if (startIndex > length2)
476 if (startIndex > length2 - length)
481 int num = startIndex + length;
482 string text =
string.FastAllocateString(length);
484 fixed (
char* ptr = text)
488 int num3 = num - stringBuilder.m_ChunkOffset;
491 if (num3 > stringBuilder.m_ChunkLength)
493 num3 = stringBuilder.m_ChunkLength;
497 int num6 = num3 - num4;
506 char[] chunkChars = stringBuilder.m_ChunkChars;
507 if ((uint)(num5 + num2) > length || (uint)(num5 + num6) > (uint)chunkChars.Length)
511 fixed (
char* smem = &chunkChars[num6])
513 string.wstrcpy(ptr + num2, smem, num5);
517 stringBuilder = stringBuilder.m_ChunkPrevious;
525 [__DynamicallyInvokable]
539 [__DynamicallyInvokable]
546 if (repeatCount == 0)
550 int num = m_ChunkLength;
551 while (repeatCount > 0)
553 if (num < m_ChunkChars.Length)
555 m_ChunkChars[num++] = value;
561 ExpandByABlock(repeatCount);
580 [SecuritySafeCritical]
581 [__DynamicallyInvokable]
592 if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8 && charCount == 0)
598 if (startIndex == 0 && charCount == 0)
604 if (charCount > value.Length - startIndex)
612 fixed (
char* value2 = &value[startIndex])
614 Append(value2, charCount);
623 [SecuritySafeCritical]
624 [__DynamicallyInvokable]
629 char[] chunkChars = m_ChunkChars;
630 int chunkLength = m_ChunkLength;
631 int length = value.Length;
632 int num = chunkLength + length;
633 if (num < chunkChars.Length)
639 chunkChars[chunkLength] = value[0];
643 chunkChars[chunkLength + 1] = value[1];
648 fixed (
char* smem = value)
650 fixed (
char* dmem = &chunkChars[chunkLength])
652 string.wstrcpy(dmem, smem, length);
666 [SecuritySafeCritical]
667 private unsafe
void AppendHelper(
string value)
669 fixed (
char* value2 = value)
671 Append(value2, value.Length);
677 internal unsafe
extern void ReplaceBufferInternal(
char* newBuffer,
int newLength);
681 internal unsafe
extern void ReplaceBufferAnsiInternal(sbyte* newBuffer,
int newLength);
694 [SecuritySafeCritical]
695 [__DynamicallyInvokable]
706 if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8 && count == 0)
712 if (startIndex == 0 && count == 0)
722 if (startIndex > value.Length - count)
726 fixed (
char* ptr = value)
728 Append(ptr + startIndex, count);
737 [__DynamicallyInvokable]
748 [__DynamicallyInvokable]
769 [SecuritySafeCritical]
770 [__DynamicallyInvokable]
771 public void CopyTo(
int sourceIndex,
char[] destination,
int destinationIndex,
int count)
773 if (destination ==
null)
781 if (destinationIndex < 0)
785 if (destinationIndex > destination.Length - count)
789 if ((uint)sourceIndex > (uint)
Length)
793 if (sourceIndex >
Length - count)
798 int num = sourceIndex + count;
799 int num2 = destinationIndex + count;
802 int num3 = num - stringBuilder.m_ChunkOffset;
805 if (num3 > stringBuilder.m_ChunkLength)
807 num3 = stringBuilder.m_ChunkLength;
810 int num5 = num3 - count;
818 ThreadSafeCopy(stringBuilder.m_ChunkChars, num5, destination, num2, num4);
820 stringBuilder = stringBuilder.m_ChunkPrevious;
833 [SecuritySafeCritical]
834 [__DynamicallyInvokable]
842 if ((uint)index > (uint)length)
846 if (value ==
null || value.Length == 0 || count == 0)
850 long num = (long)value.Length * (
long)count;
855 MakeRoom(index, (
int)num, out
StringBuilder chunk, out
int indexInChunk, doneMoveFollowingChars:
false);
856 fixed (
char* value2 = value)
860 ReplaceInPlaceAtChunk(ref chunk, ref indexInChunk, value2, value.Length);
872 [__DynamicallyInvokable]
883 if (length >
Length - startIndex)
887 if (
Length == length && startIndex == 0)
903 [__DynamicallyInvokable]
906 return Append(value.ToString());
913 [CLSCompliant(
false)]
914 [__DynamicallyInvokable]
924 [__DynamicallyInvokable]
934 [__DynamicallyInvokable]
937 if (m_ChunkLength < m_ChunkChars.Length)
939 m_ChunkChars[m_ChunkLength++] = value;
952 [__DynamicallyInvokable]
962 [__DynamicallyInvokable]
972 [__DynamicallyInvokable]
982 [__DynamicallyInvokable]
992 [__DynamicallyInvokable]
1002 [__DynamicallyInvokable]
1012 [CLSCompliant(
false)]
1013 [__DynamicallyInvokable]
1023 [CLSCompliant(
false)]
1024 [__DynamicallyInvokable]
1034 [CLSCompliant(
false)]
1035 [__DynamicallyInvokable]
1045 [__DynamicallyInvokable]
1052 return Append(value.ToString());
1059 [SecuritySafeCritical]
1060 [__DynamicallyInvokable]
1063 if (value !=
null && value.Length != 0)
1065 fixed (
char* value2 = &value[0])
1067 Append(value2, value.Length);
1079 [SecuritySafeCritical]
1080 [__DynamicallyInvokable]
1083 if ((uint)index > (uint)
Length)
1089 fixed (
char* value2 = value)
1091 Insert(index, value2, value.Length);
1104 [__DynamicallyInvokable]
1107 return Insert(index, value.ToString(), 1);
1117 [CLSCompliant(
false)]
1118 [__DynamicallyInvokable]
1131 [__DynamicallyInvokable]
1144 [__DynamicallyInvokable]
1156 [SecuritySafeCritical]
1157 [__DynamicallyInvokable]
1160 Insert(index, &value, 1);
1170 [__DynamicallyInvokable]
1173 if ((uint)index > (uint)
Length)
1179 Insert(index, value, 0, value.Length);
1196 [SecuritySafeCritical]
1197 [__DynamicallyInvokable]
1201 if ((uint)index > (uint)length)
1207 if (startIndex == 0 && charCount == 0)
1221 if (startIndex > value.Length - charCount)
1227 fixed (
char* value2 = &value[startIndex])
1229 Insert(index, value2, charCount);
1242 [__DynamicallyInvokable]
1255 [__DynamicallyInvokable]
1268 [__DynamicallyInvokable]
1281 [__DynamicallyInvokable]
1294 [__DynamicallyInvokable]
1307 [CLSCompliant(
false)]
1308 [__DynamicallyInvokable]
1321 [CLSCompliant(
false)]
1322 [__DynamicallyInvokable]
1335 [CLSCompliant(
false)]
1336 [__DynamicallyInvokable]
1349 [__DynamicallyInvokable]
1356 return Insert(index, value.ToString(), 1);
1368 [__DynamicallyInvokable]
1371 return AppendFormatHelper(
null, format,
new ParamsArray(arg0));
1384 [__DynamicallyInvokable]
1387 return AppendFormatHelper(
null, format,
new ParamsArray(arg0, arg1));
1401 [__DynamicallyInvokable]
1404 return AppendFormatHelper(
null, format,
new ParamsArray(arg0, arg1, arg2));
1416 [__DynamicallyInvokable]
1423 return AppendFormatHelper(
null, format,
new ParamsArray(args));
1436 [__DynamicallyInvokable]
1439 return AppendFormatHelper(provider, format,
new ParamsArray(arg0));
1453 [__DynamicallyInvokable]
1456 return AppendFormatHelper(provider, format,
new ParamsArray(arg0, arg1));
1471 [__DynamicallyInvokable]
1474 return AppendFormatHelper(provider, format,
new ParamsArray(arg0, arg1, arg2));
1487 [__DynamicallyInvokable]
1494 return AppendFormatHelper(provider, format,
new ParamsArray(args));
1497 private static void FormatError()
1509 int length = format.Length;
1511 ICustomFormatter customFormatter =
null;
1512 if (provider !=
null)
1514 customFormatter = (ICustomFormatter)provider.
GetFormat(typeof(ICustomFormatter));
1520 while (num < length)
1526 if (num < length && format[num] ==
'}')
1537 if (num >= length || format[num] !=
'{')
1551 if (num == length || (c = format[num]) <
'0' || c >
'9')
1558 num4 = num4 * 10 + c - 48;
1566 while (c >=
'0' && c <=
'9' && num4 < 1000000);
1567 if (num4 >= args.Length)
1569 throw new FormatException(Environment.GetResourceString(
"Format_IndexOutOfRange"));
1571 for (; num < length; num++)
1573 if ((c = format[num]) !=
' ')
1582 for (num++; num < length && format[num] ==
' '; num++)
1600 if (c < '0' || c >
'9')
1606 num5 = num5 * 10 + c - 48;
1614 while (c >=
'0' && c <=
'9' && num5 < 1000000);
1616 for (; num < length; num++)
1618 if ((c = format[num]) !=
' ')
1623 object obj = args[num4];
1640 if (num < length && format[num] ==
'{')
1651 if (num >= length || format[num] !=
'}')
1657 if (stringBuilder ==
null)
1661 stringBuilder.Append(c);
1671 string text2 =
null;
1672 if (customFormatter !=
null)
1674 if (stringBuilder !=
null)
1676 text = stringBuilder.ToString();
1678 text2 = customFormatter.Format(text, obj, provider);
1682 IFormattable formattable = obj as IFormattable;
1683 if (formattable !=
null)
1685 if (text ==
null && stringBuilder !=
null)
1687 text = stringBuilder.ToString();
1689 text2 = formattable.ToString(text, provider);
1691 else if (obj !=
null)
1693 text2 = obj.ToString();
1698 text2 =
string.Empty;
1700 int num6 = num5 - text2.Length;
1701 if (!flag && num6 > 0)
1706 if (flag && num6 > 0)
1722 [__DynamicallyInvokable]
1732 [__DynamicallyInvokable]
1748 int num = stringBuilder.m_ChunkLength;
1750 int num2 = stringBuilder2.m_ChunkLength;
1757 stringBuilder = stringBuilder.m_ChunkPrevious;
1758 if (stringBuilder ==
null)
1762 num = stringBuilder.m_ChunkLength + num;
1766 stringBuilder2 = stringBuilder2.m_ChunkPrevious;
1767 if (stringBuilder2 ==
null)
1771 num2 = stringBuilder2.m_ChunkLength + num2;
1782 while (stringBuilder.m_ChunkChars[num] == stringBuilder2.m_ChunkChars[num2]);
1798 [__DynamicallyInvokable]
1802 if ((uint)startIndex > (uint)length)
1806 if (count < 0 || startIndex > length - count)
1810 if (oldValue ==
null)
1814 if (oldValue.Length == 0)
1818 if (newValue ==
null)
1822 int num = newValue.Length - oldValue.Length;
1825 StringBuilder stringBuilder = FindChunkForIndex(startIndex);
1826 int num3 = startIndex - stringBuilder.m_ChunkOffset;
1829 if (StartsWith(stringBuilder, num3, count, oldValue))
1835 else if (num2 >= array.Length)
1837 int[] array2 =
new int[array.Length * 3 / 2 + 4];
1838 Array.
Copy(array, array2, array.Length);
1841 array[num2++] = num3;
1842 num3 += oldValue.Length;
1843 count -= oldValue.Length;
1850 if (num3 >= stringBuilder.m_ChunkLength || count == 0)
1852 int num5 = num3 + stringBuilder.m_ChunkOffset;
1854 ReplaceAllInChunk(array, num2, stringBuilder, oldValue.
Length, newValue);
1855 num5 += (newValue.Length - oldValue.Length) * num2;
1857 stringBuilder = FindChunkForIndex(num5);
1858 num3 = num5 - stringBuilder.m_ChunkOffset;
1868 [__DynamicallyInvokable]
1883 [__DynamicallyInvokable]
1887 if ((uint)startIndex > (uint)length)
1891 if (count < 0 || startIndex > length - count)
1895 int num = startIndex + count;
1899 int num2 = num - stringBuilder.m_ChunkOffset;
1900 int num3 = startIndex - stringBuilder.m_ChunkOffset;
1904 for (
int num4 =
Math.
Min(stringBuilder.m_ChunkLength, num2); i < num4; i++)
1906 if (stringBuilder.m_ChunkChars[i] == oldChar)
1908 stringBuilder.m_ChunkChars[i] = newChar;
1916 stringBuilder = stringBuilder.m_ChunkPrevious;
1931 [CLSCompliant(
false)]
1938 int num = valueCount + m_ChunkLength;
1939 if (num <= m_ChunkChars.Length)
1941 ThreadSafeCopy(value, m_ChunkChars, m_ChunkLength, valueCount);
1942 m_ChunkLength = num;
1946 int num2 = m_ChunkChars.Length - m_ChunkLength;
1949 ThreadSafeCopy(value, m_ChunkChars, m_ChunkLength, num2);
1950 m_ChunkLength = m_ChunkChars.Length;
1952 int num3 = valueCount - num2;
1953 ExpandByABlock(num3);
1954 ThreadSafeCopy(value + num2, m_ChunkChars, 0, num3);
1955 m_ChunkLength = num3;
1961 private unsafe
void Insert(
int index,
char* value,
int valueCount)
1963 if ((uint)index > (uint)
Length)
1969 MakeRoom(index, valueCount, out
StringBuilder chunk, out
int indexInChunk, doneMoveFollowingChars:
false);
1970 ReplaceInPlaceAtChunk(ref chunk, ref indexInChunk, value, valueCount);
1974 [SecuritySafeCritical]
1975 private unsafe
void ReplaceAllInChunk(
int[] replacements,
int replacementsCount,
StringBuilder sourceChunk,
int removeCount,
string value)
1977 if (replacementsCount > 0)
1979 fixed (
char* value2 = value)
1981 int num = (value.Length - removeCount) * replacementsCount;
1983 int indexInChunk = replacements[0];
1986 MakeRoom(chunk.m_ChunkOffset + indexInChunk, num, out chunk, out indexInChunk, doneMoveFollowingChars:
true);
1991 ReplaceInPlaceAtChunk(ref chunk, ref indexInChunk, value2, value.Length);
1992 int num3 = replacements[num2] + removeCount;
1994 if (num2 >= replacementsCount)
1998 int num4 = replacements[num2];
2001 fixed (
char* value3 = &sourceChunk.m_ChunkChars[num3])
2003 ReplaceInPlaceAtChunk(ref chunk, ref indexInChunk, value3, num4 - num3);
2008 indexInChunk += num4 - num3;
2013 Remove(chunk.m_ChunkOffset + indexInChunk, -num, out chunk, out indexInChunk);
2019 private bool StartsWith(
StringBuilder chunk,
int indexInChunk,
int count,
string value)
2021 for (
int i = 0; i < value.Length; i++)
2027 if (indexInChunk >= chunk.m_ChunkLength)
2029 chunk = Next(chunk);
2036 if (value[i] != chunk.m_ChunkChars[indexInChunk])
2047 private unsafe
void ReplaceInPlaceAtChunk(ref
StringBuilder chunk, ref
int indexInChunk,
char* value,
int count)
2055 int val = chunk.m_ChunkLength - indexInChunk;
2056 int num = Math.Min(val, count);
2057 ThreadSafeCopy(value, chunk.m_ChunkChars, indexInChunk, num);
2058 indexInChunk += num;
2059 if (indexInChunk >= chunk.m_ChunkLength)
2061 chunk = Next(chunk);
2075 private unsafe
static void ThreadSafeCopy(
char* sourcePtr,
char[] destination,
int destinationIndex,
int count)
2079 if ((uint)destinationIndex > (uint)destination.Length || destinationIndex + count > destination.Length)
2081 throw new ArgumentOutOfRangeException(
"destinationIndex", Environment.GetResourceString(
"ArgumentOutOfRange_Index"));
2083 fixed (
char* dmem = &destination[destinationIndex])
2085 string.wstrcpy(dmem, sourcePtr, count);
2091 private unsafe
static void ThreadSafeCopy(
char[] source,
int sourceIndex,
char[] destination,
int destinationIndex,
int count)
2095 if ((uint)sourceIndex > (uint)source.Length || sourceIndex + count > source.Length)
2097 throw new ArgumentOutOfRangeException(
"sourceIndex", Environment.GetResourceString(
"ArgumentOutOfRange_Index"));
2099 fixed (
char* sourcePtr = &source[sourceIndex])
2101 ThreadSafeCopy(sourcePtr, destination, destinationIndex, count);
2107 internal unsafe
void InternalCopy(IntPtr dest,
int len)
2112 byte* ptr = (
byte*)dest.ToPointer();
2116 int num = stringBuilder.m_ChunkOffset * 2;
2117 int len2 = stringBuilder.m_ChunkLength * 2;
2118 fixed (
char* ptr2 = &stringBuilder.m_ChunkChars[0])
2120 byte* src = (
byte*)ptr2;
2124 Buffer.Memcpy(ptr + num, src, len - num);
2128 Buffer.Memcpy(ptr + num, src, len2);
2131 stringBuilder = stringBuilder.m_ChunkPrevious;
2133 while (stringBuilder !=
null);
2140 while (stringBuilder.m_ChunkOffset > index)
2142 stringBuilder = stringBuilder.m_ChunkPrevious;
2144 return stringBuilder;
2150 while (stringBuilder.m_ChunkOffset * 2 > byteIndex)
2152 stringBuilder = stringBuilder.m_ChunkPrevious;
2154 return stringBuilder;
2163 return FindChunkForIndex(chunk.m_ChunkOffset + chunk.m_ChunkLength);
2166 private void ExpandByABlock(
int minBlockCharCount)
2168 if (minBlockCharCount + Length < minBlockCharCount || minBlockCharCount + Length > m_MaxCapacity)
2170 throw new ArgumentOutOfRangeException(
"requiredLength", Environment.GetResourceString(
"ArgumentOutOfRange_SmallCapacity"));
2172 int num = Math.Max(minBlockCharCount, Math.Min(
Length, 8000));
2174 m_ChunkOffset += m_ChunkLength;
2176 if (m_ChunkOffset + num < num)
2178 m_ChunkChars =
null;
2179 throw new OutOfMemoryException();
2181 m_ChunkChars =
new char[num];
2186 m_ChunkLength = from.m_ChunkLength;
2187 m_ChunkOffset = from.m_ChunkOffset;
2188 m_ChunkChars = from.m_ChunkChars;
2189 m_ChunkPrevious = from.m_ChunkPrevious;
2190 m_MaxCapacity = from.m_MaxCapacity;
2193 [SecuritySafeCritical]
2194 private unsafe
void MakeRoom(
int index,
int count, out
StringBuilder chunk, out
int indexInChunk,
bool doneMoveFollowingChars)
2196 if (count + Length < count || count + Length > m_MaxCapacity)
2198 throw new ArgumentOutOfRangeException(
"requiredLength", Environment.GetResourceString(
"ArgumentOutOfRange_SmallCapacity"));
2201 while (chunk.m_ChunkOffset > index)
2203 chunk.m_ChunkOffset += count;
2204 chunk = chunk.m_ChunkPrevious;
2206 indexInChunk = index - chunk.m_ChunkOffset;
2207 if (!doneMoveFollowingChars && chunk.m_ChunkLength <= 32 && chunk.m_ChunkChars.Length - chunk.m_ChunkLength >= count)
2209 int num = chunk.m_ChunkLength;
2210 while (num > indexInChunk)
2213 chunk.m_ChunkChars[num + count] = chunk.m_ChunkChars[num];
2215 chunk.m_ChunkLength += count;
2219 stringBuilder.m_ChunkLength = count;
2220 int num2 = Math.Min(count, indexInChunk);
2223 char[] chunkChars = chunk.m_ChunkChars;
2224 fixed (
char* ptr = chunkChars)
2226 ThreadSafeCopy(ptr, stringBuilder.m_ChunkChars, 0, num2);
2227 int num3 = indexInChunk - num2;
2230 ThreadSafeCopy(ptr + num2, chunk.m_ChunkChars, 0, num3);
2231 indexInChunk = num3;
2235 chunk.m_ChunkPrevious = stringBuilder;
2236 chunk.m_ChunkOffset += count;
2239 chunk = stringBuilder;
2240 indexInChunk = num2;
2246 m_ChunkChars =
new char[size];
2247 m_MaxCapacity = maxCapacity;
2248 m_ChunkPrevious = previousBlock;
2249 if (previousBlock !=
null)
2251 m_ChunkOffset = previousBlock.m_ChunkOffset + previousBlock.m_ChunkLength;
2255 [SecuritySafeCritical]
2256 private void Remove(
int startIndex,
int count, out
StringBuilder chunk, out
int indexInChunk)
2258 int num = startIndex + count;
2264 if (num - chunk.m_ChunkOffset >= 0)
2266 if (stringBuilder ==
null)
2268 stringBuilder = chunk;
2269 num2 = num - stringBuilder.m_ChunkOffset;
2271 if (startIndex - chunk.m_ChunkOffset >= 0)
2278 chunk.m_ChunkOffset -= count;
2280 chunk = chunk.m_ChunkPrevious;
2282 indexInChunk = startIndex - chunk.m_ChunkOffset;
2283 int num3 = indexInChunk;
2284 int count2 = stringBuilder.m_ChunkLength - num2;
2285 if (stringBuilder != chunk)
2288 chunk.m_ChunkLength = indexInChunk;
2289 stringBuilder.m_ChunkPrevious = chunk;
2290 stringBuilder.m_ChunkOffset = chunk.m_ChunkOffset + chunk.m_ChunkLength;
2291 if (indexInChunk == 0)
2293 stringBuilder.m_ChunkPrevious = chunk.m_ChunkPrevious;
2294 chunk = stringBuilder;
2297 stringBuilder.m_ChunkLength -= num2 - num3;
2300 ThreadSafeCopy(stringBuilder.m_ChunkChars, num2, stringBuilder.m_ChunkChars, num3, count2);
static string NewLine
Gets the newline string defined for this environment.
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
StringBuilder AppendFormat(string format, params object[] args)
Appends the string returned by processing a composite format string, which contains zero or more form...
StringBuilder Insert(int index, short value)
Inserts the string representation of a specified 16-bit signed integer into this instance at the spec...
unsafe override string ToString()
Converts the value of this instance to a T:System.String.
StringBuilder Append(byte value)
Appends the string representation of a specified 8-bit unsigned integer to this instance.
unsafe StringBuilder Insert(int index, string value, int count)
Inserts one or more copies of a specified string into this instance at the specified character positi...
StringBuilder Insert(int index, ulong value)
Inserts the string representation of a 64-bit unsigned integer into this instance at the specified ch...
StringBuilder AppendFormat(IFormatProvider provider, string format, params object[] args)
Appends the string returned by processing a composite format string, which contains zero or more form...
StringBuilder()
Initializes a new instance of the T:System.Text.StringBuilder class.
StringBuilder(int capacity, int maxCapacity)
Initializes a new instance of the T:System.Text.StringBuilder class that starts with a specified capa...
StringBuilder Append(int value)
Appends the string representation of a specified 32-bit signed integer to this instance.
static sbyte Min(sbyte val1, sbyte val2)
Returns the smaller of two 8-bit signed integers.
StringBuilder Append(ushort value)
Appends the string representation of a specified 16-bit unsigned integer to this instance.
bool Equals(StringBuilder sb)
Returns a value indicating whether this instance is equal to a specified object.
The exception that is thrown when the value of an argument is outside the allowable range of values a...
StringBuilder Insert(int index, ushort value)
Inserts the string representation of a 16-bit unsigned integer into this instance at the specified ch...
int EnsureCapacity(int capacity)
Ensures that the capacity of this instance of T:System.Text.StringBuilder is at least the specified v...
unsafe StringBuilder Append(char *value, int valueCount)
Appends an array of Unicode characters starting at a specified address to this instance.
StringBuilder AppendFormat(string format, object arg0, object arg1)
Appends the string returned by processing a composite format string, which contains zero or more form...
StringBuilder Append(bool value)
Appends the string representation of a specified Boolean value to this instance.
StringBuilder AppendLine()
Appends the default line terminator to the end of the current T:System.Text.StringBuilder object.
StringBuilder Insert(int index, decimal value)
Inserts the string representation of a decimal number into this instance at the specified character p...
Describes the source and destination of a given serialized stream, and provides an additional caller-...
StringBuilder Insert(int index, object value)
Inserts the string representation of an object into this instance at the specified character position...
unsafe StringBuilder Append(char[] value)
Appends the string representation of the Unicode characters in a specified array to this instance.
StringBuilder Append(long value)
Appends the string representation of a specified 64-bit signed integer to this instance.
StringBuilder AppendFormat(string format, object arg0)
Appends the string returned by processing a composite format string, which contains zero or more form...
StringBuilder Append(ulong value)
Appends the string representation of a specified 64-bit unsigned integer to this instance.
StringBuilder AppendLine(string value)
Appends a copy of the specified string followed by the default line terminator to the end of the curr...
StringBuilder Insert(int index, bool value)
Inserts the string representation of a Boolean value into this instance at the specified character po...
StringBuilder(int capacity)
Initializes a new instance of the T:System.Text.StringBuilder class using the specified capacity.
StringBuilder Append(uint value)
Appends the string representation of a specified 32-bit unsigned integer to this instance.
unsafe StringBuilder Append(string value)
Appends a copy of the specified string to this instance.
Provides information about, and means to manipulate, the current environment and platform....
void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count)
Copies the characters from a specified segment of this instance to a specified segment of a destinati...
StringBuilder Append(char value, int repeatCount)
Appends a specified number of copies of the string representation of a Unicode character to this inst...
The exception that is thrown when an attempt is made to access an element of an array or collection w...
StringBuilder Append(object value)
Appends the string representation of a specified object to this instance.
StringBuilder AppendFormat(IFormatProvider provider, string format, object arg0, object arg1)
Appends the string returned by processing a composite format string, which contains zero or more form...
StringBuilder Append(sbyte value)
Appends the string representation of a specified 8-bit signed integer to this instance.
StringBuilder Append(decimal value)
Appends the string representation of a specified decimal number to this instance.
StringBuilder(string value)
Initializes a new instance of the T:System.Text.StringBuilder class using the specified string.
static sbyte Max(sbyte val1, sbyte val2)
Returns the larger of two 8-bit signed integers.
unsafe string ToString(int startIndex, int length)
Converts the value of a substring of this instance to a T:System.String.
int Length
Gets or sets the length of the current T:System.Text.StringBuilder object.
StringBuilder Insert(int index, sbyte value)
Inserts the string representation of a specified 8-bit signed integer into this instance at the speci...
unsafe StringBuilder Append(string value, int startIndex, int count)
Appends a copy of a specified substring to this instance.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
The exception that is thrown when there is not enough memory to continue the execution of a program.
The exception thrown when an error occurs during serialization or deserialization.
MethodImplOptions
Defines the details of how a method is implemented.
StringBuilder Append(double value)
Appends the string representation of a specified double-precision floating-point number to this insta...
int MaxCapacity
Gets the maximum capacity of this instance.
Stores all the data needed to serialize or deserialize an object. This class cannot be inherited.
StringBuilder Insert(int index, int value)
Inserts the string representation of a specified 32-bit signed integer into this instance at the spec...
Represents a mutable string of characters. This class cannot be inherited.To browse the ....
StringBuilder Replace(char oldChar, char newChar, int startIndex, int count)
Replaces, within a substring of this instance, all occurrences of a specified character with another ...
StringBuilder AppendFormat(string format, object arg0, object arg1, object arg2)
Appends the string returned by processing a composite format string, which contains zero or more form...
StringBuilder Append(float value)
Appends the string representation of a specified single-precision floating-point number to this insta...
StringBuilder Insert(int index, double value)
Inserts the string representation of a double-precision floating-point number into this instance at t...
static CultureInfo CurrentCulture
Gets or sets the T:System.Globalization.CultureInfo object that represents the culture used by the cu...
The exception that is thrown when one of the arguments provided to a method is not valid.
StringBuilder Append(short value)
Appends the string representation of a specified 16-bit signed integer to this instance.
StringBuilder Append(char value)
Appends the string representation of a specified T:System.Char object to this instance.
unsafe StringBuilder Insert(int index, string value)
Inserts a string into this instance at the specified character position.
static void Copy(Array sourceArray, Array destinationArray, int length)
Copies a range of elements from an T:System.Array starting at the first element and pastes them into ...
Allows an object to control its own serialization and deserialization.
unsafe StringBuilder Insert(int index, char value)
Inserts the string representation of a specified Unicode character into this instance at the specifie...
unsafe StringBuilder(string value, int startIndex, int length, int capacity)
Initializes a new instance of the T:System.Text.StringBuilder class from the specified substring and ...
int Capacity
Gets or sets the maximum number of characters that can be contained in the memory allocated by the cu...
StringBuilder Replace(string oldValue, string newValue)
Replaces all occurrences of a specified string in this instance with another specified string.
StringBuilder Insert(int index, long value)
Inserts the string representation of a 64-bit signed integer into this instance at the specified char...
unsafe StringBuilder Insert(int index, char[] value, int startIndex, int charCount)
Inserts the string representation of a specified subarray of Unicode characters into this instance at...
StringBuilder Replace(char oldChar, char newChar)
Replaces all occurrences of a specified character in this instance with another specified character.
Specifies that the class can be serialized.
string Name
Gets the name for the item currently being examined.
StringBuilder AppendFormat(IFormatProvider provider, string format, object arg0)
Appends the string returned by processing a composite format string, which contains zero or more form...
StringBuilder Clear()
Removes all characters from the current T:System.Text.StringBuilder instance.
Provides information about a specific culture (called a locale for unmanaged code development)....
Provides constants and static methods for trigonometric, logarithmic, and other common mathematical f...
StringBuilder Replace(string oldValue, string newValue, int startIndex, int count)
Replaces, within a substring of this instance, all occurrences of a specified string with another spe...
A conditional operation, such as a > b ? a : b in C# or If(a > b, a, b) in Visual Basic.
StringBuilder Insert(int index, float value)
Inserts the string representation of a single-precision floating point number into this instance at t...
Provides a formatter-friendly mechanism for parsing the data in T:System.Runtime.Serialization....
StringBuilder Insert(int index, char[] value)
Inserts the string representation of a specified array of Unicode characters into this instance at th...
void GetObjectData(SerializationInfo info, StreamingContext context)
Populates a T:System.Runtime.Serialization.SerializationInfo with the data needed to serialize the ta...
StringBuilder Insert(int index, uint value)
Inserts the string representation of a 32-bit unsigned integer into this instance at the specified ch...
StringBuilder AppendFormat(IFormatProvider provider, string format, object arg0, object arg1, object arg2)
Appends the string returned by processing a composite format string, which contains zero or more form...
StringBuilder Insert(int index, byte value)
Inserts the string representation of a specified 8-bit unsigned integer into this instance at the spe...
StringBuilder Remove(int startIndex, int length)
Removes the specified range of characters from this instance.
unsafe StringBuilder Append(char[] value, int startIndex, int charCount)
Appends the string representation of a specified subarray of Unicode characters to this instance.
bool MoveNext()
Updates the enumerator to the next item.