Why is the Pair class in a UI namespace?

  • Thread starter Thread starter John
  • Start date Start date
J

John

Can anybody tell me why MS would put such a basic data structure, like
System.Web.UI.Pair, into a UI namespace?

The Pair class, to me, is something you use just as much at a deeper level
as you would at the UI level..

But I can only assume the namespace of each .NET class was well thought out
and put there for a reason I can't comprehend. So what the hell am I
missing? Or did somebody just throw it into the wrong namespace?

Thanks in advance,
John
 
I would assume that it is available higher up since it could be used as
a fairly generic data structure.

Why burry a generic class down into the depths of a namespace tree if
several classes/methods could use it either directly or indirectly.

MSDN has a small example of its use:

public ICollection GetFilesToProcess(DirectoryInfo directory) {

ArrayList filesAndAttributes = new ArrayList();

foreach (FileSystemInfo fsi in directory.GetFileSystemInfos())
{
if( fsi is FileInfo ) {
string name = fsi.FullName;
FileAttributes attr = fsi.Attributes;
Pair p = new Pair ();
p.First = name;
p.Second = attr;
filesAndAttributes.Add(p);
}
}

return filesAndAttributes;
}

I guess it would be just as easy to do it other ways, but the Pair
class offers a simple way to designate a generic two property class.
 
gmiley said:
I would assume that it is available higher up since it could be used as
a fairly generic data structure.
[snip]

It is available, as long as I include a reference to system.web.dll in my
model assembly.

Basically, the way I code is I write a model assembly with all the business
level coding and db interaction. Then I write the asp pages using the model
assembly. The benefit is that I can reuse the model assembly in other
places like maybe a future webservice or something ... who knows.

So obviously, I don't want to tie my model assembly to the system.web.dll.
And that's the only way to reference it ... that I know of anyway.

The best course of action is to rewrite the simple class ... but I just feel
foolish rewriting something that's already there!

As I said earlier, I can only assume I'm missing something.

Thanks,
John
 
I see, I misunderstood your first post. I am not sure why something as
basic as the Pair class would be down in Web.UI - I would think it
should be in System.Collections{} or System.Collections.Specialized{}.

Regardless, as redundant as it is:

public class Pair : System.Object
{
public object First;
public object Second;

public Pair() {}
public Pair(object first object second)
{
First = first;
Second = second;
}
}
 
gmiley said:
I see, I misunderstood your first post. I am not sure why something as
basic as the Pair class would be down in Web.UI - I would think it
should be in System.Collections{} or System.Collections.Specialized{}.

Regardless, as redundant as it is:

public class Pair : System.Object
{
public object First;
public object Second;

public Pair() {}
public Pair(object first object second)
{
First = first;
Second = second;
}
}

Thanks but I already created (duplicated) it.

Honestly, the more I think about it ... the more I think it wasn't planned,
but just thrown into the namespace it was being used for what ever project
at MS.

If anybody has a comment on why it might logically be there ... I'd love to
hear it.

Sincerely,
John
 
Back
Top