Recursive WebRequest.Create()



The WebRequest class implements IWebRequestCreate and hence, a method
Create.

This method has two other overloads, one of which is a private method.
Here's how it looks:

public static WebRequest Create(string requestUriString)
public static WebRequest Create(Uri requestUri)
private static WebRequest Create(Uri requestUri, bool useUriBase)


Both the public overloads with a single argument internally call the
private overload with the second parameter as false. The implementation
of the private method is given below:


private static WebRequest Create(Uri requestUri, bool useUriBase)
{
string text1;
WebRequestPrefixElement element1 = null;
bool flag1 = false;
if (!useUriBase)
{
text1 = requestUri.AbsoluteUri;
}
else
{
text1 = requestUri.Scheme + ':';
}
int num1 = text1.Length;
ArrayList list1 = WebRequest.PrefixList;
for (int num2 = 0; num2 < list1.Count; num2++)
{
element1 = (WebRequestPrefixElement) list1[num2];
if ((num1 >= element1.Prefix.Length) &&
(string.Compare(element1.Prefix, 0, text1, 0, element1.Prefix.Length,
true, CultureInfo.InvariantCulture) == 0))
{
flag1 = true;
break;
}
}
if (!flag1)
{
throw new
NotSupportedException(SR.GetString("net_unknown_prefix"));
}
return element1.Creator.Create(requestUri);
}


I was surprised to see the last statement of this private overload
calling one of the other public overloads. Isn't this recursive, or am
I missing something here?

.



Relevant Pages

  • Re: overloading
    ... > I have a function 'Private MyFunc(ByVal dbS as String) As Boolean' where ... 'Private Overloads MyFuncAs ... I added the Overloads keyword to the original also, ... > overloading change the requirements of Private/Public? ...
    (microsoft.public.dotnet.languages.vb)
  • overloading
    ... I have a function 'Private MyFunc(ByVal dbS as String) As Boolean' where dbS ... is a database value determined by the database reader method. ... I added the Overloads keyword to the original also, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Late binding -- Calling a static method
    ... meaning the constructor is ... private, ... There are other overloads of GetMethod that allow you to pass the types ...
    (microsoft.public.dotnet.framework)
  • Overloads/Shadows question
    ... I'm developing a form which is to be used as an enhanced MessageBox(). ... a parameterless version of Show. ... have even worked) to simply make a Private version of Showand only ... the other overloads? ...
    (microsoft.public.dotnet.languages.vb)