/// <summary>
        /// Retrieve objects of the given predicate; number of objects is already set in the template query
        /// </summary>
        private static async Task RetrieveObjectsOfPredicate(PredicateResultWrapper predicate, SparqlParameterizedString template)
        {
            var queryText = new SparqlParameterizedString(template.ToString());

            queryText.SetPredicate(predicate.ToString());
            var query   = QueryParsing.ParseQuery(queryText);
            var results = await QueryProcessing.ProcessQuery(query, predicate.Endpoint);

            if (results is SparqlResultSet)
            {
                SparqlResultSet set = (SparqlResultSet)results;
                foreach (var obj in set)
                {
                    predicate.AddObject(new ObjectWrapper(obj[0], predicate.Endpoint));
                }
            }
            else if (results is AsyncError)
            {
                throw new BrowserException(ErrorProcessing.ProcessAsyncError((AsyncError)results));
            }
            else
            {
                throw new BrowserException("An unexpected error occured while processing the query.");
            }
            //template.UnsetPredicate(); //no more reusing
        }
        /// <summary>
        /// Get the SparqlResultSet together with the endpoint it came from
        /// </summary>
        private static async Task <ResultHolder> RetrieveResultHolder(SparqlQuery query, SparqlRemoteEndpoint endpoint)
        {
            object results = await QueryProcessing.ProcessQuery(query, endpoint);

            if (results is SparqlResultSet)
            {
                SparqlResultSet set = (SparqlResultSet)results;
                return(new ResultHolder(endpoint, set));
            }
            else if (results is AsyncError)
            {
                throw new BrowserException(ErrorProcessing.ProcessAsyncError((AsyncError)results));
            }
            else
            {
                throw new BrowserException("An unexpected error occured while processing the query.");
            }
        }