I have a dialog which populates my ConnectionStringData
object with the URL of the service that I'm trying to connect to. I then consume that URL with the following property:
/// <summary>
/// Where the Service is located.
/// </summary>
public string ServiceLocation
{
get
{
string fullUrl = ConnectionStringData.Location.Trim();
if (fullUrl.EndsWith("/"))
{
fullUrl += "Routes";
}
else
{
fullUrl += "/Routes";
}
Uri uri = null;
if(Uri.TryCreate(fullUrl, UriKind.Absolute, out uri))
{
return uri.ToString();
}
throw new UriFormatException(String.Format("{0} is an invalid url", fullUrl));
}
}
Should I be doing work like this in the getter? Can I do this better?
uri
tonull
,out
will take care of that. \$\endgroup\$