Beispiel #1
0
 internal static byte[] EncodeCString(string str, SmppEncodingService smppEncodingService)
 {
     if (str == null)
     {
         str = "";
     }
     return(smppEncodingService.GetBytesFromCString(str));
 }
Beispiel #2
0
        /// <summary>
        /// Sets the given TLV(as a string)into the table.
        /// This will reverse the byte order in the tag for you (necessary for encoding).
        /// If the value is null, the parameter TLV will be removed instead.
        /// </summary>
        /// <param name="tag">The tag for this TLV.</param>
        /// <param name="val">The value of this TLV.</param>
        public void SetOptionalParamString(Tag tag, string val, bool nullTerminated = false)
        {
            if (val == null)
            {
                this.RemoveOptionalParameter(tag);
            }
            else
            {
                var bytes = vSmppEncodingService.GetBytesFromCString(val, nullTerminated);

                SetOptionalParamBytes(tag, bytes);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Sets the given TLV(as a string)into the table.
        /// This will reverse the byte order in the tag for you (necessary for encoding).
        /// If the value is null, the parameter TLV will be removed instead.
        /// </summary>
        /// <param name="tag">The tag for this TLV.</param>
        /// <param name="val">The value of this TLV.</param>
        public void SetOptionalParamString(Tag tag, string val, bool nullTerminated = false)
        {
            if (val == null)
            {
                this.RemoveOptionalParameter(tag);
            }
            else
            {
                var bytes = vSmppEncodingService.GetBytesFromCString(val);

                // Add a null byte to the end if needed.
                if (nullTerminated)
                {
                    Array.Resize(ref bytes, bytes.Length + 1);
                }

                SetOptionalParamBytes(tag, bytes);
            }
        }