/// <summary> /// Initializes the SecureBufferAdapter to carry a list of buffers to the native api. /// </summary> /// <param name="buffers"></param> public SecureBufferAdapter(IList <SecureBuffer> buffers) : base() { this.buffers = buffers; this.disposed = false; this.bufferHandles = new GCHandle[this.buffers.Count]; this.bufferCarrier = new SecureBufferInternal[this.buffers.Count]; for (int i = 0; i < this.buffers.Count; i++) { this.bufferHandles[i] = GCHandle.Alloc(this.buffers[i].Buffer, GCHandleType.Pinned); this.bufferCarrier[i] = new SecureBufferInternal(); this.bufferCarrier[i].Type = this.buffers[i].Type; this.bufferCarrier[i].Count = this.buffers[i].Buffer.Length; this.bufferCarrier[i].Buffer = bufferHandles[i].AddrOfPinnedObject(); } this.bufferCarrierHandle = GCHandle.Alloc(bufferCarrier, GCHandleType.Pinned); this.descriptor = new SecureBufferDescInternal(); this.descriptor.Version = SecureBufferDescInternal.ApiVersion; this.descriptor.NumBuffers = this.buffers.Count; this.descriptor.Buffers = bufferCarrierHandle.AddrOfPinnedObject(); this.descriptorHandle = GCHandle.Alloc(descriptor, GCHandleType.Pinned); }
/// <summary> /// Initializes the SecureBufferAdapter to carry a list of buffers to the native api. /// </summary> /// <param name="buffers"></param> public SecureBufferAdapter( IList<SecureBuffer> buffers ) : base() { this.buffers = buffers; this.disposed = false; this.bufferHandles = new GCHandle[this.buffers.Count]; this.bufferCarrier = new SecureBufferInternal[this.buffers.Count]; for ( int i = 0; i < this.buffers.Count; i++ ) { this.bufferHandles[i] = GCHandle.Alloc( this.buffers[i].Buffer, GCHandleType.Pinned ); this.bufferCarrier[i] = new SecureBufferInternal(); this.bufferCarrier[i].Type = this.buffers[i].Type; this.bufferCarrier[i].Count = this.buffers[i].Buffer.Length; this.bufferCarrier[i].Buffer = bufferHandles[i].AddrOfPinnedObject(); } this.bufferCarrierHandle = GCHandle.Alloc( bufferCarrier, GCHandleType.Pinned ); this.descriptor = new SecureBufferDescInternal(); this.descriptor.Version = SecureBufferDescInternal.ApiVersion; this.descriptor.NumBuffers = this.buffers.Count; this.descriptor.Buffers = bufferCarrierHandle.AddrOfPinnedObject(); this.descriptorHandle = GCHandle.Alloc( descriptor, GCHandleType.Pinned ); }