dotnetrdf
dotnetrdf copied to clipboard
ISparqlResultsHandler Design Issue
In ISparqlResultsHandler.cs you guys defined a function of: bool HandleResult(ISparqlResult result);
. However the parser always create a new instance of SparqlResult
.
Is it possible add one more function inside ISparqlResultsHandler:
ISparqlResult CreateResult();
The parser will invoke this function to create the ISparqlResult object. In this case, if I want to create my own implementation of ISparqlResultsHandler, I can construct my own implementation of ISparqlResult object.
Thanks
Tao
I think it would maybe be better to allow a factory to be injected when you build the query processor rather than in the handler as generating the results is really the concern of the query processor.
I'm thinking we could add support for this by extending VDS.RDF.Query.LeviathanQueryOptions
to allow a factory instance to be passed in, this would implement a simple interface with a MakeResult
method on it that would be invoked with an IEnumerable<KeyValuePair<string, INode>>
that provides the bindings for the result and returns a single ISparqlResult
instance. Would that work for your use case?
Either way is fine. Just thought extending the interface is a lot easier since the implementation class has to implement this interface anyway.