private void addTextToBucket(Person otherPerson, Text thisMsg) { if (PeopleToTexts.ContainsKey(otherPerson)) { LinkedList<Text> textBucket = (LinkedList<Text>)PeopleToTexts[otherPerson]; textBucket.AddFirst(thisMsg); PeopleToTexts[otherPerson] = textBucket; } else { LinkedList<Text> textBucket = new LinkedList<Text>(); textBucket.AddFirst(thisMsg); PeopleToTexts.Add(otherPerson, textBucket); } }
private Person initilizeMyself() { Person myself = new Person(); myself.name = "Me"; myself.phone = ""; phonesToPeople.Add(myself.phone, myself); return myself; }
private Text setTextValues(XmlElement msg, Person myself, Person otherPerson) { Text thisMsg = new Text(); String timestamp = msg.GetAttribute("t"); int direction = int.Parse(msg.GetAttribute("d")); thisMsg.from = direction == 0 ? myself : otherPerson; thisMsg.to = direction == 0 ? otherPerson : myself; thisMsg.timestamp = timestamp; thisMsg.msg = msg.InnerText; return thisMsg; }
private Person getPerson(String phonenumber) { Person otherPerson; phonenumber = parsePhoneNumber(phonenumber); if (phonesToPeople.ContainsKey(phonenumber)) //we have gotten a text from this person before { otherPerson = (Person)phonesToPeople[phonenumber]; } else //first text from this person { otherPerson = new Person(); otherPerson.phone = phonenumber; otherPerson.msgCount = 0; otherPerson.name = "Unknown"; phonesToPeople.Add(phonenumber, otherPerson); } return otherPerson; }