/// <summary> /// Asynchronously reads data into the current <see cref="SearchPreview"/>. /// </summary> /// <param name="reader"> /// The <see cref="XmlReader"/> from which to read. /// </param> /// <returns> /// A <see cref="Task"/> representing the operation. /// </returns> public async Task ReadXmlAsync(XmlReader reader) { Contract.Requires<ArgumentNullException>(reader != null); //// Intitialize data members this.metadata = new SearchResultMetadata(); await metadata.ReadXmlAsync(reader); var results = new List<SearchResult>(); this.Results = new ReadOnlyCollection<SearchResult>(results); //// Read the search preview while (!(reader.NodeType == XmlNodeType.EndElement && reader.Name == "results")) { var result = new SearchResult(this.metadata); await result.ReadXmlAsync(reader); results.Add(result); await reader.ReadAsync(); } }