public Conversation GetEntry(string key) { ConversationWrapper value = null; if (this.ConversationMap.TryGetValue(key, out value)) { return(value.Conversation); } Conversation conversation = Conversations.Retrieve(key); this.ConversationMap.Add(conversation.Id, new ConversationWrapper(conversation, DateTimeOffset.UtcNow.ToUnixTimeSeconds())); return(conversation); }
public void InsertEntry(Conversation entry) { ConversationWrapper newConversation = new ConversationWrapper(entry, DateTimeOffset.UtcNow.ToUnixTimeSeconds()); if (this.ConversationMap.ContainsKey(entry.Id)) { foreach (KeyValuePair <string, ConversationWrapper> conversation in this.ConversationMap) { if (conversation.Key.Equals(entry.Id)) { this.ConversationMap[conversation.Key] = newConversation; break; } } } else { this.ConversationMap.Add(entry.Id, newConversation); } this.Conversations.Insert(entry); }