I'd like to override HttpStyleUriParser, since I only want to modify it slightly. Microsoft also states (See MSDN)
Microsoft strongly recommends that you use a parser shipped with the .NET Framework. Building your own parser increases the complexity of your application, and will not perform as well as the shipped parsers.
However, when I try to inherit from HttpStyleUriParser, my code is never called. When I inherit from GenericUriParser, my code is called, but then I need to parse from scratch.
Finding this, I wrote a regex to valid the URL format I want to support. Then I realized it would need to be called many many times even for a single URL to get each component, as the GetComponent method has the following prototype:
protected virtual string GetComponents(
Uri uri,
UriComponents components,
UriFormat format)
So... What IS the best way to make an UriParser for HTTP-like URLs? The documentation is pretty sparse.
EDIT: After a bit more thought, the regex should probably be applied inside the InitializeAndValidate method, and saved as state inside the parser. That means I should probably create new instances of the parser for every Uri? For every thread?