/// <summary> /// Returns the BSTR preamble count of strings from the head of the memory buffer. /// </summary> /// <returns></returns> private long BCount() { if (SafePtr is null || SafePtr.handle == IntPtr.Zero) { return(0L); } switch (SizeDescriptorLength) { case 2: { return(SafePtr.get_UShortAt(0L)); } case 4: { return(SafePtr.get_UIntegerAt(0L)); } case 8: { return((long)SafePtr.get_ULongAt(0L)); } default: { return(0L); } } }
/// <summary> /// Removes the string at the specified index. /// </summary> /// <param name="index">Index of string to remove.</param> public void RemoveAt(int index) { if (index < 0 || index > Count - 1) { return; } IntPtr b = (IntPtr)(_index[index].ToInt64() - SafePtr.handle.ToInt64()); if (_lpwstr) { int c = get_LengthAt(index) * 2 + 2; _mem.PullIn((long)b, c); } else { int c = get_LengthAt(index) * 2 + SizeDescriptorLength; _mem.PullIn((long)b, c); switch (SizeDescriptorLength) { case 2: { _mem.get_UShortAt(0L); break; } case 4: { _mem.get_UIntegerAt(0L); break; } case 8: { _mem.get_ULongAt(0L); break; } } } Refresh(); }
public static object BytesToEnum(byte[] b, Type t) { SafePtr sp = b; int x = Blob.BlobTypeSize(Blob.TypeToBlobType(t.GetEnumUnderlyingType())); switch (x) { case 1: { if (Native.Unsigned(t)) { return(Enum.ToObject(t, sp[0L])); } else { return(Enum.ToObject(t, sp.get_SByteAt(0L))); } break; } case 2: { if (Native.Unsigned(t)) { return(Enum.ToObject(t, sp.get_UShortAt(0L))); } else { return(Enum.ToObject(t, sp.get_ShortAt(0L))); } break; } case 4: { if (Native.Unsigned(t)) { return(Enum.ToObject(t, sp.get_UIntegerAt(0L))); } else { return(Enum.ToObject(t, sp.get_IntegerAt(0L))); } break; } case 8: { if (Native.Unsigned(t)) { return(Enum.ToObject(t, sp.get_ULongAt(0L))); } else { return(Enum.ToObject(t, sp.get_LongAt(0L))); } break; } } return(null); }