void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs args) { MetadataViewModel model = Resources["MetadataModel"] as MetadataViewModel; if (model != null) { SearchResultsType results = (SearchResultsType)args.Result; model.Metadata.Clear(); if (results.Items != null) { foreach (var item in results.Items) { RecordType record = (RecordType)item; string title = null; string uri = null; string uuid = null; string creator = null; for (int i = 0; i < record.ItemsElementName.Length; i++) { var name = record.ItemsElementName[i]; var value = record.Items[i].Text != null ? record.Items[i].Text[0] : null; if (name == ItemsChoiceType24.title) { title = value; } else if (name == ItemsChoiceType24.URI && value != null && value.StartsWith("http")) { uri = value; } else if (name == ItemsChoiceType24.identifier) { uuid = value; } else if (name == ItemsChoiceType24.creator) { creator = value; } } model.Metadata.Add(new Metadata { Title = title, Uri = uri, Uuid = uuid, Creator = creator }); } lblStatus.Content = "Showing " + results.numberOfRecordsReturned + " of total " + results.numberOfRecordsMatched + " matches."; } else { lblStatus.Content = "No match!"; } } }
public MainWindow() { InitializeComponent(); MetadataViewModel model = Resources["MetadataModel"] as MetadataViewModel; if (model != null) { model.Metadata = new ObservableCollection <Metadata>(new List <Metadata>()); } _geonorgeApi = new GeoNorge(); }