/// <summary> /// Creates a new Base Parser Context /// </summary> /// <param name="handler">RDF Handler</param> /// <param name="traceParsing">Whether to trace parsing</param> public BaseParserContext(IRdfHandler handler, bool traceParsing) { if (handler == null) { throw new ArgumentNullException("handler"); } _handler = handler; _traceParsing = traceParsing; _baseUri = _handler.GetBaseUri(); }
/// <summary> /// Gets the Base URI from the RDF Handler. /// </summary> /// <param name="handler">RDF Handler.</param> /// <returns></returns> internal static Uri GetBaseUri(this IRdfHandler handler) { if (handler is GraphHandler) { return(((GraphHandler)handler).BaseUri); } else if (handler is IWrappingRdfHandler) { IRdfHandler temp = ((IWrappingRdfHandler)handler).InnerHandlers.FirstOrDefault(h => h.GetBaseUri() != null); if (temp == null) { return(null); } else { return(temp.GetBaseUri()); } } else { return(null); } }
/// <summary> /// Creates a new Parser Context which uses Streaming parsing. /// </summary> /// <param name="handler">RDF Handler.</param> /// <param name="input">Input.</param> public RdfXmlParserContext(IRdfHandler handler, TextReader input) : base(handler) { _queue = new StreamingEventQueue <IRdfXmlEvent>(new StreamingEventGenerator(input, handler.GetBaseUri().ToSafeString())); }
/// <summary> /// Creates a new Parser Context which uses Streaming parsing /// </summary> /// <param name="handler">RDF Handler</param> /// <param name="stream">Stream</param> public RdfXmlParserContext(IRdfHandler handler, Stream stream) : base(handler) { this._queue = new StreamingEventQueue <IRdfXmlEvent>(new StreamingEventGenerator(stream, handler.GetBaseUri().ToSafeString())); }