/// <summary> /// Create a native PAC_INFO_BUFFER of instance of current class, /// leaves cbBufferSize and Offset empty. /// </summary> /// <returns>The native PAC_INFO_BUFFER of instance of current class.</returns> internal PAC_INFO_BUFFER CreateNativeInfoBuffer() { PAC_INFO_BUFFER nativeInfo = new PAC_INFO_BUFFER(); nativeInfo.ulType = GetBufferInfoType(); return nativeInfo; }
/// <summary> /// Create a native PAC_INFO_BUFFER of instance of current class, /// leaves cbBufferSize and Offset empty. /// </summary> /// <returns>The native PAC_INFO_BUFFER of instance of current class.</returns> internal PAC_INFO_BUFFER CreateNativeInfoBuffer() { PAC_INFO_BUFFER nativeInfo = new PAC_INFO_BUFFER(); nativeInfo.ulType = GetBufferInfoType(); return(nativeInfo); }
/// <summary> /// Decode the specified PAC_TYPE buffer into an instance of PacInfoBuffer, /// according to specified PAC_INFO_BUFFER native structure. /// </summary> /// <param name="nativePacInfoBuffer">The specified PAC_INFO_BUFFER native structure.</param> /// <param name="buffer">The specified PAC_TYPE buffer.</param> /// <returns>The decoded instance of PacInfoBuffer.</returns> internal static PacInfoBuffer DecodeBuffer(PAC_INFO_BUFFER nativePacInfoBuffer, byte[] buffer) { PacInfoBuffer pacInfoBuffer = CreatePacInfoBuffer(nativePacInfoBuffer.ulType); pacInfoBuffer.DecodeBuffer( buffer, (int)nativePacInfoBuffer.Offset, (int)nativePacInfoBuffer.cbBufferSize); return pacInfoBuffer; }
/// <summary> /// Decode the specified PAC_TYPE buffer into an instance of PacInfoBuffer, /// according to specified PAC_INFO_BUFFER native structure. /// </summary> /// <param name="nativePacInfoBuffer">The specified PAC_INFO_BUFFER native structure.</param> /// <param name="buffer">The specified PAC_TYPE buffer.</param> /// <returns>The decoded instance of PacInfoBuffer.</returns> static internal PacInfoBuffer DecodeBuffer(PAC_INFO_BUFFER nativePacInfoBuffer, byte[] buffer) { PacInfoBuffer pacInfoBuffer = CreatePacInfoBuffer(nativePacInfoBuffer.ulType); pacInfoBuffer.DecodeBuffer( buffer, (int)nativePacInfoBuffer.Offset, (int)nativePacInfoBuffer.cbBufferSize); return(pacInfoBuffer); }
/// <summary> /// Assert buffers[index].cbBufferSiz == length. /// Else throw ArgumentException. /// </summary> /// <param name="buffers">The specified PAC_INFO_BUFFER[] array.</param> /// <param name="index">The specified array index.</param> /// <param name="length">The expected length of array element's cbBufferSize.</param> private static void AssertBufferSize(PAC_INFO_BUFFER[] buffers, int index, int length) { if (buffers[index].cbBufferSize != length) { throw new ArgumentException( string.Format("NativePacType.Buffers[{0}].cbBufferSize {1} != length {2}", index, buffers[index].cbBufferSize, length)); } }