protected override void PostDeserialize() { base.PostDeserialize(); foreach (var bot in Bots) { // Link up inheritance first if (!string.IsNullOrEmpty(bot.BasedOn)) { var baseBot = Bots.FirstOrDefault(b => b.Id == bot.BasedOn); if (baseBot == null) { throw new TfsNotificationRelayException(String.Format("Unknown basedOn ({0}) for bot {1}", bot.BasedOn, bot.Id)); } bot.BaseBot = baseBot; } var text = this.Texts.FirstOrDefault(t => t.Id == bot.TextId); if (text == null) { throw new TfsNotificationRelayException(String.Format("Unknown textId ({0}) for bot {1}", bot.TextId, bot.Id)); } bot.Text = text; if (!string.IsNullOrEmpty(bot.UserMapId)) { var userMap = UserMaps.FirstOrDefault(m => m.Id == bot.UserMapId); if (userMap == null) { throw new TfsNotificationRelayException(String.Format("Unknown userMapId ({0}) for bot {1}", bot.UserMapId, bot.Id)); } bot.UserMap = userMap; } else { bot.UserMap = new UserMapElement(); } } }
public Bot GetCurrentBot() { var bot = Bots.FirstOrDefault(entry => entry.IsInContext); return(bot); }