示例#1
0
        private CallingLocation ReadLocationEntry(LINETRANSLATECAPS lcl, byte[] rawBuffer, int pos)
        {
            var lce  = new LINELOCATIONENTRY();
            int size = Marshal.SizeOf(lce);

            pos = lcl.dwLocationListOffset + (pos * size);
            IntPtr pLce = Marshal.AllocHGlobal(size);

            Marshal.Copy(rawBuffer, pos, pLce, size);
            Marshal.PtrToStructure(pLce, lce);
            Marshal.FreeHGlobal(pLce);

            // Locate the country
            Country locCountry = _countries.FirstOrDefault(country => country.Id == lce.dwCountryID);

            // Locate the default calling card (if any)
            CallingCard card = null;

            if (lce.dwPreferredCardID < _cards.Count)
            {
                card = _cards[lce.dwPreferredCardID];
            }

            return(new CallingLocation(lce.dwPermanentLocationID, card,
                                       NativeMethods.GetString(rawBuffer, lce.dwLocationNameOffset, lce.dwLocationNameSize, NativeMethods.STRINGFORMAT_UNICODE), locCountry,
                                       NativeMethods.GetString(rawBuffer, lce.dwCityCodeOffset, lce.dwCityCodeSize, NativeMethods.STRINGFORMAT_UNICODE),
                                       NativeMethods.GetString(rawBuffer, lce.dwLocalAccessCodeOffset, lce.dwLocalAccessCodeSize, NativeMethods.STRINGFORMAT_UNICODE),
                                       NativeMethods.GetString(rawBuffer, lce.dwLongDistanceAccessCodeOffset, lce.dwLongDistanceAccessCodeSize, NativeMethods.STRINGFORMAT_UNICODE),
                                       NativeMethods.GetString(rawBuffer, lce.dwTollPrefixListOffset, lce.dwTollPrefixListSize, NativeMethods.STRINGFORMAT_UNICODE),
                                       NativeMethods.GetString(rawBuffer, lce.dwCancelCallWaitingOffset, lce.dwCancelCallWaitingSize, NativeMethods.STRINGFORMAT_UNICODE), lce.dwOptions));
        }
示例#2
0
 /// <summary>
 /// Constructor
 /// </summary>
 internal CallingLocation(int id, CallingCard card, string name, Country country, string cityCode, string localCode, string ldCode, string prefixes, string cancelCW, int features)
 {
     Id   = id;
     Name = name;
     PreferredCallingCard = card;
     Country                 = country;
     CityCode                = cityCode;
     LocalAccessCode         = localCode;
     LongDistanceAccessCode  = ldCode;
     _tollPrefixes           = prefixes.Length > 0 ? prefixes.Split(',') : new string[0];
     CancelCallWaitingPrefix = cancelCW;
     _features               = features;
 }