Esempio n. 1
0
        /// <summary>
        /// Decodes an address out of a PDU string.
        /// </summary>
        /// <param name="pdu">The PDU string to use.</param>
        /// <param name="index">The index where to start in the string.</param>
        /// <param name="address">The address (phone number) read.</param>
        /// <param name="addressType">The address type of the read address.</param>
        public static void DecodeGeneralAddress(string pdu, ref int index, out string address, out byte addressType)
        {
            int num;
            int num1 = index;
            int num2 = num1;

            index = num1 + 1;
            byte num3 = BcdWorker.GetByte(pdu, num2);
            int  num4 = index;
            int  num5 = num4;

            index       = num4 + 1;
            addressType = BcdWorker.GetByte(pdu, num5);
            if (num3 <= 0)
            {
                address = string.Empty;
                return;
            }
            else
            {
                bool flag = false;
                if (num3 % 2 != 0)
                {
                    num = num3 + 1;
                }
                else
                {
                    num = (int)num3;
                }
                int length = num / 2;
                if (index * 2 + length * 2 > pdu.Length - length * 2)
                {
                    length = (pdu.Length - index * 2) / 2;
                    flag   = true;
                }
                AddressType addressType1 = new AddressType(addressType);
                if (addressType1.Ton != 5)
                {
                    string bytesString = BcdWorker.GetBytesString(pdu, index, length);
                    index = index + length;
                    if (flag)
                    {
                        address = BcdWorker.DecodeSemiOctets(bytesString).Substring(0, length * 2);
                        return;
                    }
                    else
                    {
                        address = BcdWorker.DecodeSemiOctets(bytesString).Substring(0, num3);
                        return;
                    }
                }
                else
                {
                    byte[] bytes = BcdWorker.GetBytes(pdu, index, length);
                    index   = index + length;
                    address = PduParts.Decode7BitText(bytes);
                    return;
                }
            }
        }
Esempio n. 2
0
 protected string CreateAddressOfType(string address, byte type)
 {
     if (address != string.Empty)
     {
         if ((type == 0x91) && !address.StartsWith("+"))
         {
             return("+" + address);
         }
         AddressType type2 = new AddressType(type);
         if (type2.Ton == 5)
         {
             string s = BcdWorker.EncodeSemiOctets(address);
             return(TextDataConverter.SevenBitToString(TextDataConverter.OctetsToSeptetsStr(BcdWorker.GetBytes(s, 0, BcdWorker.CountBytes(s))), false));
         }
     }
     return(address);
 }