Ejemplo n.º 1
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         values = null;
     }
     MemoryHelpers.FreeMemory(nativeBuffer);
     nativeBuffer = IntPtr.Zero;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InterfaceArray"/> class.
 /// </summary>
 /// <param name="array">The array.</param>
 public unsafe InterfaceArray(params T[] array)
 {
     values       = array;
     nativeBuffer = IntPtr.Zero;
     if (values != null)
     {
         var length = array.Length;
         values       = new T[length];
         nativeBuffer = MemoryHelpers.AllocateMemory(length * sizeof(IntPtr));
         for (int i = 0; i < length; i++)
         {
             Set(i, array[i]);
         }
     }
 }
Ejemplo n.º 3
0
 public InterfaceArray(params T[] array)
 {
     values        = array;
     NativePointer = IntPtr.Zero;
     if (values != null)
     {
         var length = array.Length;
         values        = new T[length];
         NativePointer = MemoryHelpers.AllocateMemory(length * IntPtr.Size);
         for (int i = 0; i < length; i++)
         {
             this[i] = array[i];
         }
     }
 }
Ejemplo n.º 4
0
            private static unsafe int GetIids(IntPtr thisPtr, int *iidCount, IntPtr *iids)
            {
                try
                {
                    InspectableShadow shadow   = ToShadow <InspectableShadow>(thisPtr);
                    IInspectable      callback = (IInspectable)shadow.Callback;

                    ShadowContainer container = callback.Shadow;

                    int countGuids = container.Guids.Length;

                    // Copy GUIDs deduced from Callback
                    iids = (IntPtr *)Marshal.AllocCoTaskMem(IntPtr.Size * countGuids);
                    *iidCount = countGuids;

                    MemoryHelpers.CopyMemory((IntPtr)iids, new ReadOnlySpan <IntPtr>(container.Guids));
                }
                catch (Exception exception)
                {
                    return((int)Result.GetResultFromException(exception));
                }
                return(Result.Ok.Code);
            }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InterfaceArray"/> class.
 /// </summary>
 /// <param name="size">The size.</param>
 public unsafe InterfaceArray(int size)
 {
     values       = new T[size];
     nativeBuffer = MemoryHelpers.AllocateMemory(size * sizeof(IntPtr));
 }
Ejemplo n.º 6
0
 public InterfaceArray(int size)
 {
     values        = new T[size];
     NativePointer = MemoryHelpers.AllocateMemory(size * IntPtr.Size);
 }