/// <summary> /// Add an array of strings to the end of the collection. /// </summary> /// <param name="values">Array of strings.</param> public void AddStrings(string[] values) { if (values is null) { return; } int sdl = SizeDescriptorLength; int dl = sdl * values.Length; foreach (var s in values) { dl += s.Length * 2; } if (_lpwstr) { dl += 2 * values.Length; } long sl; IntPtr sp; long oldLen; if (SafePtr.Length <= 0L) { SafePtr.Length = sdl; } oldLen = SafePtr.Length; switch (sdl) { case 2: { SafePtr.get_UShortAt(0L); break; } case 4: { SafePtr.get_UIntegerAt(0L); break; } case 8: { SafePtr.get_ULongAt(0L); break; } } SafePtr.Length += dl; sp = SafePtr.handle + (int)oldLen; int oi; if (_index is null) { oi = 0; _index = new IntPtr[values.Length]; } else { oi = _index.Length; Array.Resize(ref _index, _index.Length + (values.Length - 1) + 1); } if (_lpwstr) { foreach (var s in values) { sl = s.Length; _index[oi] = sp; oi += 1; QuickCopyObject <string>(sp, s, (uint)(sl + sl)); sp = sp + (int)(sl + sl); MemPtr mm = sp; mm.set_ShortAt(0L, 0); sp = sp + 2; } } else { foreach (var s in values) { sl = s.Length; _index[oi] = sp; oi += 1; MemPtr mm = sp; switch (sdl) { case 2: { mm.set_UShortAt(0L, (ushort)sl); break; } case 4: { mm.set_UIntegerAt(0L, (uint)sl); break; } case 8: { mm.set_LongAt(0L, sl); break; } } sp = sp + sdl; QuickCopyObject <string>(sp, s, (uint)(sl + sl)); sp = sp + (int)(sl + sl); } } _count = _index.Length; }