protected long GetPropertyIntegerData(uint propertyId) { return(this.ExecuteGetter(() => { uint data; Util.Assert(Edsdk.EdsGetPropertyData(this.Handle, propertyId, 0, out data), string.Format("Failed to get property integer data: propertyId {0}", propertyId), propertyId); return data; })); }
internal T GetPropertyStruct <T>(uint propertyId, Edsdk.EdsDataType expectedDataType) where T : struct { return(this.ExecuteGetter(() => { var dataSize = this.GetPropertyDataSize(propertyId, expectedDataType); var ptr = Marshal.AllocHGlobal(dataSize); try { Util.Assert(Edsdk.EdsGetPropertyData(this.Handle, propertyId, 0, dataSize, ptr), "Failed to get required struct.", propertyId); return (T)Marshal.PtrToStructure(ptr, typeof(T)); } finally { Marshal.FreeHGlobal(ptr); } })); }
protected long[] GetPropertyIntegerArrayData(uint propertyId) { return(this.ExecuteGetter(() => { var dataSize = this.GetPropertyDataSize(propertyId, Edsdk.EdsDataType.UInt32_Array); var ptr = Marshal.AllocHGlobal(dataSize); try { Util.Assert(Edsdk.EdsGetPropertyData(this.Handle, propertyId, 0, dataSize, ptr), "Failed to get required struct.", propertyId); var signed = new int[dataSize / Marshal.SizeOf(typeof(uint))]; Marshal.Copy(ptr, signed, 0, signed.Length); return signed.Select(i => (long)(uint)i).ToArray(); } finally { Marshal.FreeHGlobal(ptr); } })); }