public List <string> ProcessJSONFeed(string filename) { List <string> messages = new List <string>(); using (StreamReader file = File.OpenText(filename)) { List <Selection> selections = new List <Selection>(); JsonSerializer serializer = new JsonSerializer(); JSONFeedModel feedModel = (JSONFeedModel)serializer.Deserialize(file, typeof(JSONFeedModel)); ConstructMessagesForJSONFeed(messages, selections, feedModel); } return(messages); }
private static void ConstructMessagesForJSONFeed(List <string> messages, List <Selection> selections, JSONFeedModel feedModel) { feedModel.RawData.Markets.ToList().ForEach(market => { selections.AddRange(market.Selections); }); messages.Add(feedModel.RawData.FixtureName); selections.OrderBy(s => s.Price).ToList().ForEach(selection => { messages.Add($"Name: {selection.Tags.name}. Price: {selection.Price}."); }); }