private async Task <IList <Weapon> > GetWeaponsAsync(Task <string> contentProvider, WeaponType weaponType) { Stopwatch sw = Instrumentation.BeginNetworkMeasure(); string content = await contentProvider; Instrumentation.EndNetworkMeasure(sw); sw = Instrumentation.BeginProcessingMeasure(); IList <Weapon> result = ProcessContent(content, weaponType); Instrumentation.EndProcessingMeasure(sw); return(result); }
private async Task <IList <Weapon> > CreateWeapons(HttpClient httpClient, string weaponType) { Stopwatch sw = Instrumentation.BeginNetworkMeasure(); string content = await httpClient.GetStringAsync($"https://mhw-db.com/weapons?q={{%22type%22:%22{weaponType}%22}}&p={{%22crafting%22:false,%22assets%22:false}}"); Instrumentation.EndNetworkMeasure(sw); sw = Instrumentation.BeginProcessingMeasure(); var inputWeapons = (JArray)JsonConvert.DeserializeObject(content); WeaponType typedWeaponType = ConvertWeaponType(weaponType); var outputWeapons = new List <Weapon>(); for (int i = 0; i < inputWeapons.Count; i++) { outputWeapons.Add(CreateWeapon((JObject)inputWeapons[i], typedWeaponType)); } Instrumentation.EndProcessingMeasure(sw); return(outputWeapons); }