void serviceDocParserParseComplete(ServiceDocument serviceDocument, Exception Error) { if (Error == null) { this.serviceDocument = serviceDocument; Dispatcher.BeginInvoke(new DocumentDownloadCompletedDelegate(DisplayServiceCollections), null); } }
public void BeginParse(string ServiceUri) { serviceUri = ServiceUri; if (!String.IsNullOrEmpty(ServiceUri)) { HttpWebRequest webRequest = WebRequest.Create(ServiceUri) as HttpWebRequest; webRequest.BeginGetResponse( (asResult) => { try { HttpWebResponse webResponse = webRequest.EndGetResponse(asResult) as HttpWebResponse; if (webResponse.StatusCode == HttpStatusCode.OK) { XDocument xDocServiceDocument = XDocument.Load(webResponse.GetResponseStream()); parseInternal(xDocServiceDocument.Root); ServiceDocument serviceDocument = new ServiceDocument() { EntitySetUris = entitySetLinks, BaseUri = baseUri }; RaiseParseComplete(serviceDocument, null); } else { RaiseParseComplete(null, new Exception("Failure downloading service document")); } } catch { String userMessage = String.Format( "We failed to download the Service Document.\r\n Here is the URI we tried : {0} .\r\n Please check the Data Service Uri by trying it in a browser" , this.serviceUri ); RaiseParseComplete(null, new Exception(userMessage)); } }, null); } }
private void RaiseParseComplete(ServiceDocument serviceDocument, Exception Error) { if (this.ParseComplete != null) { ParseComplete(serviceDocument, Error); } }