示例#1
0
 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;
     }));
 }
示例#2
0
 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);
         }
     }));
 }
示例#3
0
        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);
                }
            }));
        }