Beispiel #1
0
        /// <summary>
        ///
        /// Encapsulate the oodss client requst in a simpler GetMetadata call.
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public async Task <Document> RequestMetadata(ParsedUri uri)
        {
            Document result = null;

            if (_metadataClient != null)
            {
                Debug.WriteLine("Performing asynchronous call");
                ResponseMessage metadataResponse =
                    _metadataClient.RequestAsync(new MetadataRequest(uri.ToString())).Result;
                Debug.WriteLine("Received asynchronous request ");

                if (metadataResponse != null && metadataResponse is MetadataResponse)
                {
                    result = (metadataResponse as MetadataResponse).Metadata;
                }
                else if (metadataResponse != null && metadataResponse is SemanticServiceError)
                {
                    (metadataResponse as SemanticServiceError).Perform();
                }
                else
                {
                    throw new Exception();
                }
            }
            else
            {
                var requestUri = new ParsedUri(_serviceBaseUri, "?url=" + uri.AbsoluteUri);
                result = await _metadataTypeScope.DeserializeUri(requestUri, Format.Xml) as Document;
            }

            return(result);
        }