/// <summary> /// Asynchronously reads a collection of <see cref="Protein"/> objects from a file. /// </summary> public static async Task <ICollection <Protein> > ReadFileAsync(this IProteinCollectionSerializer serializer, string path) { using (var stream = File.OpenRead(path)) { return(await serializer.DeserializeAsync(stream).ConfigureAwait(false)); } }
/// <summary> /// Asynchronously reads a collection of <see cref="Protein"/> objects from a resource described by a <see cref="Uri"/>. /// </summary> public static async Task <ICollection <Protein> > ReadUriAsync(this IProteinCollectionSerializer serializer, Uri address) { var client = new WebClient(); using (var stream = await client.OpenReadTaskAsync(address).ConfigureAwait(false)) { return(await serializer.DeserializeAsync(stream).ConfigureAwait(false)); } }