/// <summary>
        /// Marshal the PDU struct to a byte array.
        /// </summary>
        /// <param name="binaryWriter">BinaryWriter</param>
        internal override void ToBytes(BinaryWriter binaryWriter)
        {
            base.ToBytes(binaryWriter);

            binaryWriter.Write(max_xmit_frag);
            binaryWriter.Write(max_recv_frag);
            binaryWriter.Write(assoc_group_id);

            binaryWriter.Write(sec_addr.length);
            binaryWriter.Write(sec_addr.port_spec);

            if (pad2 != null)
            {
                binaryWriter.Write(pad2);
            }

            binaryWriter.Write(p_result_list.n_results);
            binaryWriter.Write(p_result_list.reserved);
            binaryWriter.Write(p_result_list.reserved2);

            if (p_result_list.p_results != null)
            {
                for (int i = 0; i < p_result_list.p_results.Length; i++)
                {
                    binaryWriter.Write((ushort)p_result_list.p_results[i].result);
                    binaryWriter.Write((ushort)p_result_list.p_results[i].reason);

                    binaryWriter.Write(p_result_list.p_results[i].transfer_syntax.if_uuid.ToByteArray());
                    binaryWriter.Write(p_result_list.p_results[i].transfer_syntax.if_version);
                }
            }

            RpceUtility.AuthVerifierToBytes(binaryWriter, auth_verifier);
        }
        /// <summary>
        /// Marshal the PDU struct to a byte array.
        /// </summary>
        /// <param name="binaryWriter">BinaryWriter</param>
        internal override void ToBytes(BinaryWriter binaryWriter)
        {
            base.ToBytes(binaryWriter);

            binaryWriter.Write(max_xmit_frag);
            binaryWriter.Write(max_recv_frag);
            binaryWriter.Write(assoc_group_id);

            binaryWriter.Write(p_context_elem.n_context_elem);
            binaryWriter.Write(p_context_elem.reserved);
            binaryWriter.Write(p_context_elem.reserved2);

            if (p_context_elem.p_cont_elem != null)
            {
                for (int i = 0; i < p_context_elem.p_cont_elem.Length; i++)
                {
                    binaryWriter.Write(p_context_elem.p_cont_elem[i].p_cont_id);
                    binaryWriter.Write(p_context_elem.p_cont_elem[i].n_transfer_syn);
                    binaryWriter.Write(p_context_elem.p_cont_elem[i].reserved);
                    binaryWriter.Write(p_context_elem.p_cont_elem[i].abstract_syntax.if_uuid.ToByteArray());
                    binaryWriter.Write(p_context_elem.p_cont_elem[i].abstract_syntax.if_version);
                    if (p_context_elem.p_cont_elem[i].transfer_syntaxes != null)
                    {
                        for (int j = 0; j < p_context_elem.p_cont_elem[i].transfer_syntaxes.Length; j++)
                        {
                            binaryWriter.Write(
                                p_context_elem.p_cont_elem[i].transfer_syntaxes[j].if_uuid.ToByteArray());
                            binaryWriter.Write(p_context_elem.p_cont_elem[i].transfer_syntaxes[j].if_version);
                        }
                    }
                }
            }

            RpceUtility.AuthVerifierToBytes(binaryWriter, auth_verifier);
        }
        /// <summary>
        /// Marshal the PDU struct to a byte array.
        /// </summary>
        /// <param name="binaryWriter">BinaryWriter</param>
        internal override void ToBytes(BinaryWriter binaryWriter)
        {
            base.ToBytes(binaryWriter);

            binaryWriter.Write(alloc_hint);
            binaryWriter.Write(p_cont_id);
            binaryWriter.Write(cancel_count);
            binaryWriter.Write(reserved);

            if (stub != null)
            {
                binaryWriter.Write(stub);
            }

            RpceUtility.AuthVerifierToBytes(binaryWriter, auth_verifier);
        }
        /// <summary>
        /// Marshal the PDU struct to a byte array.
        /// </summary>
        /// <param name="binaryWriter">BinaryWriter</param>
        internal override void ToBytes(BinaryWriter binaryWriter)
        {
            base.ToBytes(binaryWriter);

            binaryWriter.Write(alloc_hint);
            binaryWriter.Write(p_cont_id);
            binaryWriter.Write(opnum);

            if (@object != null)
            {
                binaryWriter.Write(@object.Value.ToByteArray());
            }

            if (stub != null)
            {
                binaryWriter.Write(stub);
            }

            RpceUtility.AuthVerifierToBytes(binaryWriter, auth_verifier);
        }
 /// <summary>
 /// Marshal the PDU struct to a byte array.
 /// </summary>
 /// <param name="binaryWriter">BinaryWriter</param>
 internal override void ToBytes(BinaryWriter binaryWriter)
 {
     base.ToBytes(binaryWriter);
     binaryWriter.Write(pad);
     RpceUtility.AuthVerifierToBytes(binaryWriter, auth_verifier);
 }