/// <summary> Called to create a SubmitMulti object </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="buf"></param>
        /// <param name="offset"></param>
        /// <returns> SubmitMulti </returns>
        public static SubmitMultiSm Create(DataCodings defaultEncoding, SmppBuffer buf, ref int offset)
        {
            SubmitMultiSm submitMulti = new SubmitMultiSm(defaultEncoding);

            try
            {
                int start_offset = offset;

                buf.ExtractHeader(submitMulti, ref offset);

                submitMulti.ServiceType          = buf.ExtractCString(ref offset);
                submitMulti.SourceTon            = buf.ExtractByte(ref offset);
                submitMulti.SourceNpi            = buf.ExtractByte(ref offset);
                submitMulti.SourceAddr           = buf.ExtractCString(ref offset);
                submitMulti.DestinationAddresses = buf.ExtractDestinationAddresses(ref offset);
                submitMulti.EsmClass             = buf.ExtractByte(ref offset);
                submitMulti.ProtocolId           = buf.ExtractByte(ref offset);
                submitMulti.PriorityFlag         = buf.ExtractByte(ref offset);
                submitMulti.ScheduleDeliveryTime = buf.ExtractCString(ref offset);
                submitMulti.ValidityPeriod       = buf.ExtractCString(ref offset);
                submitMulti.RegisteredDelivery   = buf.ExtractByte(ref offset);
                submitMulti.ReplaceIfPresent     = buf.ExtractByte(ref offset);
                submitMulti.DataCoding           = (DataCodings)buf.ExtractByte(ref offset);
                submitMulti.DefaultMsgId         = buf.ExtractByte(ref offset);
                submitMulti.ShortMessageLength   = buf.ExtractByte(ref offset);

                if (submitMulti.ShortMessageLength > 0)
                {
                    submitMulti.UserDataBuffer = new SmppBuffer(defaultEncoding, buf.ExtractByteArray(ref offset, submitMulti.ShortMessageLength));
                }

                while (offset - start_offset < submitMulti.Length)
                {
                    submitMulti.Optional.Add(buf.ExtractTLV(ref offset));
                }
            }

            catch
            {
                submitMulti = null;
            }

            return(submitMulti);
        }