public ItemResult[] Read(IntPtr dataPtr, IntPtr errorsPtr) { try { var position = 0; var result = new ItemResult[size]; for (var i = 0; i < size; i++) { // ReSharper disable UseObjectOrCollectionInitializer result[i] = new ItemResult(); // ReSharper restore UseObjectOrCollectionInitializer // uint hServer; result[i].ServerId = Marshal.ReadInt32(dataPtr, position); position += sizeof(int); // ushort vtCanonicalDataType; var type = Marshal.ReadInt16(dataPtr, position); position += sizeof(short); if (type > (short)VarEnum.VT_VECTOR) { result[i].CanonicalDataType = (VarEnum)(type & 0xFF00); result[i].CanonicalDataSubType = (VarEnum)(type & 0x00FF); } else { result[i].CanonicalDataType = (VarEnum)type; result[i].CanonicalDataSubType = VarEnum.VT_EMPTY; } // ushort wReserved; position += sizeof(short); // uint dwAccessRights; result[i].AccessRights = Marshal.ReadInt32(dataPtr, position); position += sizeof(int); // uint dwBlobSize; var blobSize = Marshal.ReadInt32(dataPtr, position); position += sizeof(int); // IntPtr pBlob; var blob = Marshal.ReadIntPtr(dataPtr, position); position += IntPtr.Size; if (blob != IntPtr.Zero) { result[i].Blob = new byte[blobSize]; for (var blobByteIndex = 0; blobByteIndex < blobSize; blobByteIndex++) { result[i].Blob[blobByteIndex] = Marshal.ReadByte(blob, blobByteIndex); } Marshal.FreeCoTaskMem(blob); } result[i].Error = Marshal.ReadInt32(errorsPtr, i * sizeof(int)); } return(result); } finally { Marshal.FreeCoTaskMem(dataPtr); Marshal.FreeCoTaskMem(errorsPtr); } }
public ItemResult[] Read(IntPtr dataPtr, IntPtr errorsPtr) { try { var position = 0; var result = new ItemResult[size]; for (var i = 0; i < size; i++) { // ReSharper disable UseObjectOrCollectionInitializer result[i] = new ItemResult(); // ReSharper restore UseObjectOrCollectionInitializer // uint hServer; result[i].ServerId = Marshal.ReadInt32(dataPtr, position); position += sizeof(int); // ushort vtCanonicalDataType; var type = Marshal.ReadInt16(dataPtr, position); position += sizeof(short); if (type > (short)VarEnum.VT_VECTOR) { result[i].CanonicalDataType = (VarEnum)(type & 0xFF00); result[i].CanonicalDataSubType = (VarEnum)(type & 0x00FF); } else { result[i].CanonicalDataType = (VarEnum)type; result[i].CanonicalDataSubType = VarEnum.VT_EMPTY; } // ushort wReserved; position += sizeof(short); // uint dwAccessRights; result[i].AccessRights = Marshal.ReadInt32(dataPtr, position); position += sizeof(int); // uint dwBlobSize; var blobSize = Marshal.ReadInt32(dataPtr, position); position += sizeof(int); // IntPtr pBlob; var blob = Marshal.ReadIntPtr(dataPtr, position); position += IntPtr.Size; if (blob != IntPtr.Zero) { result[i].Blob = new byte[blobSize]; for (var blobByteIndex = 0; blobByteIndex < blobSize; blobByteIndex++) result[i].Blob[blobByteIndex] = Marshal.ReadByte(blob, blobByteIndex); Marshal.FreeCoTaskMem(blob); } result[i].Error = Marshal.ReadInt32(errorsPtr, i * sizeof(int)); } return result; } finally { Marshal.FreeCoTaskMem(dataPtr); Marshal.FreeCoTaskMem(errorsPtr); } }
public DAGroupItemNode(Item item, ItemResult result) { Name = item.ItemId + (result.Error != 0 ? "(" + result.Error + ")" : ""); Icon = "/Images/DAGroup.png"; }