Ejemplo n.º 1
0
 /// <summary>
 /// Gets the concatenation information of a message.
 /// </summary>
 /// <param name="pdu">The message to get the information of.</param>
 /// <returns>An object implementing <see cref="T:GSMCommunication.PDUDecoder.SmartMessaging.IConcatenationInfo" />, if
 /// the message is a part of a concatenated message, null otherwise.</returns>
 /// <remarks>
 /// <para>The returned information can be used to discover the parts of a concatenated message
 /// or recombine the parts back into one message.</para>
 /// </remarks>
 public static IConcatenationInfo GetConcatenationInfo(SmsPdu pdu)
 {
     if (pdu != null)
     {
         IConcatenationInfo concatenationInfo = null;
         if (pdu.UserDataHeaderPresent)
         {
             byte[] userDataHeader = pdu.GetUserDataHeader();
             InformationElement[] informationElementArray  = SmartMessageDecoder.DecodeUserDataHeader(userDataHeader);
             InformationElement[] informationElementArray1 = informationElementArray;
             int num = 0;
             while (num < (int)informationElementArray1.Length)
             {
                 InformationElement informationElement = informationElementArray1[num];
                 if (informationElement as IConcatenationInfo == null)
                 {
                     num++;
                 }
                 else
                 {
                     concatenationInfo = (IConcatenationInfo)informationElement;
                     break;
                 }
             }
         }
         return(concatenationInfo);
     }
     else
     {
         throw new ArgumentNullException("pdu");
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a user data header out of information elements.
 /// </summary>
 /// <param name="elements">The <see cref="T:GSMCommunication.PDUDecoder.SmartMessaging.InformationElement" /> instances to be stored in the header.</param>
 /// <returns>A byte array containing the user data header.</returns>
 /// <exception cref="T:System.ArgumentNullException">elements is null.</exception>
 /// <exception cref="T:System.ArgumentException">The sum of all elements is too large, size exceeds 255 bytes.</exception>
 public static byte[] CreateUserDataHeader(InformationElement[] elements)
 {
     if (elements != null)
     {
         List <byte> nums = new List <byte>();
         nums.Add(0);
         int length = 0;
         InformationElement[] informationElementArray = elements;
         for (int i = 0; i < (int)informationElementArray.Length; i++)
         {
             InformationElement informationElement = informationElementArray[i];
             byte[]             byteArray          = informationElement.ToByteArray();
             nums.AddRange(byteArray);
             length = length + (int)byteArray.Length;
         }
         if (length <= 255)
         {
             nums[0] = (byte)length;
             return(nums.ToArray());
         }
         else
         {
             throw new ArgumentException("The sum of all elements is too large, size exceeds 255 bytes.");
         }
     }
     else
     {
         throw new ArgumentNullException("elements");
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a user data header out of information elements.
 /// </summary>
 /// <param name="element">The <see cref="T:GSMCommunication.PDUDecoder.SmartMessaging.InformationElement" /> instance to be stored in the header.</param>
 /// <returns>A byte array containing the user data header.</returns>
 /// <exception cref="T:System.ArgumentNullException">element is null.</exception>
 /// <exception cref="T:System.ArgumentException">Element is too large, size exceeds 255 bytes.</exception>
 public static byte[] CreateUserDataHeader(InformationElement element)
 {
     if (element != null)
     {
         byte[] byteArray = element.ToByteArray();
         if ((int)byteArray.Length <= 255)
         {
             byte[] length = new byte[(int)byteArray.Length + 1];
             length[0] = (byte)((int)byteArray.Length);
             byteArray.CopyTo(length, 1);
             return(length);
         }
         else
         {
             throw new ArgumentException("Element is to large, size exceeds 255 bytes.");
         }
     }
     else
     {
         throw new ArgumentNullException("element");
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates a user data header out of information elements.
 /// </summary>
 /// <param name="elements">The <see cref="T:GSMCommunication.PDUDecoder.SmartMessaging.InformationElement" /> instances to be stored in the header.</param>
 /// <returns>A byte array containing the user data header.</returns>
 /// <exception cref="T:System.ArgumentNullException">elements is null.</exception>
 /// <exception cref="T:System.ArgumentException">The sum of all elements is too large, size exceeds 255 bytes.</exception>
 public static byte[] CreateUserDataHeader(InformationElement[] elements)
 {
     if (elements != null)
     {
         List<byte> nums = new List<byte>();
         nums.Add(0);
         int length = 0;
         InformationElement[] informationElementArray = elements;
         for (int i = 0; i < (int)informationElementArray.Length; i++)
         {
             InformationElement informationElement = informationElementArray[i];
             byte[] byteArray = informationElement.ToByteArray();
             nums.AddRange(byteArray);
             length = length + (int)byteArray.Length;
         }
         if (length <= 255)
         {
             nums[0] = (byte)length;
             return nums.ToArray();
         }
         else
         {
             throw new ArgumentException("The sum of all elements is too large, size exceeds 255 bytes.");
         }
     }
     else
     {
         throw new ArgumentNullException("elements");
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Creates a user data header out of information elements.
 /// </summary>
 /// <param name="element">The <see cref="T:GSMCommunication.PDUDecoder.SmartMessaging.InformationElement" /> instance to be stored in the header.</param>
 /// <returns>A byte array containing the user data header.</returns>
 /// <exception cref="T:System.ArgumentNullException">element is null.</exception>
 /// <exception cref="T:System.ArgumentException">Element is too large, size exceeds 255 bytes.</exception>
 public static byte[] CreateUserDataHeader(InformationElement element)
 {
     if (element != null)
     {
         byte[] byteArray = element.ToByteArray();
         if ((int)byteArray.Length <= 255)
         {
             byte[] length = new byte[(int)byteArray.Length + 1];
             length[0] = (byte)((int)byteArray.Length);
             byteArray.CopyTo(length, 1);
             return length;
         }
         else
         {
             throw new ArgumentException("Element is to large, size exceeds 255 bytes.");
         }
     }
     else
     {
         throw new ArgumentNullException("element");
     }
 }