subclassing System.Uri

  • Thread starter Thread starter Eric Newton
  • Start date Start date
E

Eric Newton

It would be nice to be able to subclass the System.Uri class easier,

since there's no empty constructor, its not easy to define a more typed Uri
that possibly takes specific arguments and formats them to a "company
standard" or standards compliant URI

(quick example)
I eventually want to get to this:
Dim s as new SearcherUri(State:="FL", CountyName:="Sarasota",
BookType:=BookType.OfficialRecords, BookNumber:=33333, PageNumber:=444)

but currently I have to settle with, for example, the State passed through a
CountyFipsCode which is basically "FL##" (for florida) or "TN##"

so the current SearcherUri.New looks like this
MyBase.New(string.Format("searcher://servername/{0}/{1}/{2}?{3},{4}",countyF
ipsCode.Substring(0,2),countyName,iif(bookType=BookType.OfficialRecords,"OR"
),bookNumber,pageNumber)
m_state = countyFipsCode.Substring(0,2)

obviously the constructor call is VERY messy, and look at the IIF for
shortening "OfficialRecords" to "OR", and look at the inefficiency of having
to Substring(0,2) twice to extract the state...

see what i'm getting at? I propose making Uri class a little more
"subclass" friendly, whereas there's more protected variables and such for
setting the various bits of the Uri

/me wishes for a CLR wish list :-)
 
Hi Eric,

You might post this in whidbey newsgroups...

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

Eric Newton said:
It would be nice to be able to subclass the System.Uri class easier,

since there's no empty constructor, its not easy to define a more typed Uri
that possibly takes specific arguments and formats them to a "company
standard" or standards compliant URI

(quick example)
I eventually want to get to this:
Dim s as new SearcherUri(State:="FL", CountyName:="Sarasota",
BookType:=BookType.OfficialRecords, BookNumber:=33333, PageNumber:=444)

but currently I have to settle with, for example, the State passed through a
CountyFipsCode which is basically "FL##" (for florida) or "TN##"

so the current SearcherUri.New looks like this
MyBase.New(string.Format("searcher://servername/{0}/{1}/{2}?{3},{4}",countyFipsCode.Substring(0,2),countyName,iif(bookType=BookType.OfficialRecords,"OR"
),bookNumber,pageNumber)
m_state = countyFipsCode.Substring(0,2)

obviously the constructor call is VERY messy, and look at the IIF for
shortening "OfficialRecords" to "OR", and look at the inefficiency of having
to Substring(0,2) twice to extract the state...

see what i'm getting at? I propose making Uri class a little more
"subclass" friendly, whereas there's more protected variables and such for
setting the various bits of the Uri

/me wishes for a CLR wish list :-)

--
Eric Newton
C#/ASP Application Developer
http://ensoft-software.com/
(e-mail address removed)-software.com [remove the first "CC."]
 
Back
Top