readAreaCodeMap() public method

public readAreaCodeMap ( String>.SortedDictionary sortedAreaCodeMap ) : void
sortedAreaCodeMap String>.SortedDictionary
return void
 public static AreaCodeMap ParseAreaCodeMap(Stream stream)
 {
     SortedDictionary<int, String> areaCodeMapTemp = new SortedDictionary<int, String>();
     using (var lines = new StreamReader(stream, Encoding.UTF8))
     {
         String line;
         while ((line = lines.ReadLine()) != null)
         {
             line = line.Trim();
             if (line.Length <= 0 || line[0] == '#')
                 continue;
             var indexOfPipe = line.IndexOf('|');
             if (indexOfPipe == -1)
             {
                 continue;
             }
             String areaCode = line.Substring(0, indexOfPipe);
             String location = line.Substring(indexOfPipe + 1);
             areaCodeMapTemp[int.Parse(areaCode)] = location;
         }
         // Build the corresponding area code map and serialize it to the binary format.
         AreaCodeMap areaCodeMap = new AreaCodeMap();
         areaCodeMap.readAreaCodeMap(areaCodeMapTemp);
         return areaCodeMap;
     }
 }
Beispiel #2
0
        public static AreaCodeMap ParseAreaCodeMap(Stream stream)
        {
            SortedDictionary <int, String> areaCodeMapTemp = new SortedDictionary <int, String>();

            using (var lines = new StreamReader(stream, Encoding.UTF8))
            {
                String line;
                while ((line = lines.ReadLine()) != null)
                {
                    line = line.Trim();
                    if (line.Length <= 0 || line[0] == '#')
                    {
                        continue;
                    }
                    var indexOfPipe = line.IndexOf('|');
                    if (indexOfPipe == -1)
                    {
                        continue;
                    }
                    String areaCode = line.Substring(0, indexOfPipe);
                    String location = line.Substring(indexOfPipe + 1);
                    areaCodeMapTemp[int.Parse(areaCode)] = location;
                }
                // Build the corresponding area code map and serialize it to the binary format.
                AreaCodeMap areaCodeMap = new AreaCodeMap();
                areaCodeMap.readAreaCodeMap(areaCodeMapTemp);
                return(areaCodeMap);
            }
        }