public CallerList LoadPhonebookFromFile()
        {
            var dialogResult = OpenFileDialog();

            if (dialogResult != DialogResult.OK)
            {
                return(null);
            }

            fileStream = File.OpenRead(path);

            var callerList = new CallerList();

            using (StreamReader streamReader = new StreamReader(fileStream))
            {
                while (!streamReader.EndOfStream)
                {
                    string line = streamReader.ReadLine();

                    if (!string.IsNullOrEmpty(line))
                    {
                        string[] columns = line.Split(new string[] { COLUMN_SEPARATOR }, StringSplitOptions.RemoveEmptyEntries);

                        if (columns.Length == 2)
                        {
                            callerList.Add(new Caller(new Record(columns[0], columns[1])));
                        }
                    }
                }
            }

            return(callerList);
        }
Exemplo n.º 2
0
 public void AddRecord(Record newRecord)
 {
     callerList.Add(new Caller(newRecord));
 }