G
Guest
Basically I'd like to implement the composite design pattern with leaves that
are either of reference or value types, but even using generics I can't seem
to avoid boxing (using ArrayList or Object)
Is this even possible, or is the composite pattern doomed to use the
System.Object type forever?
I have tried using interfaces with generics, but I always stumble on the
Value property (when trying to return the value of a particular node)
I'd like to record the children in a
System.Collections.Generic.Dictionary<string, Node>
I can't create any Node class that fills in the blank, no matter how I try.
I always run into having to have two differnt kinds of Value properties for
the Node item -- one for refernce types and one for value types, and if I
have to differentiate, then I lose the benefit of the pattern, and if I
don't... all I can see as a way out is Boxing...
Am I trying to do something that's impossible here?
are either of reference or value types, but even using generics I can't seem
to avoid boxing (using ArrayList or Object)
Is this even possible, or is the composite pattern doomed to use the
System.Object type forever?
I have tried using interfaces with generics, but I always stumble on the
Value property (when trying to return the value of a particular node)
I'd like to record the children in a
System.Collections.Generic.Dictionary<string, Node>
I can't create any Node class that fills in the blank, no matter how I try.
I always run into having to have two differnt kinds of Value properties for
the Node item -- one for refernce types and one for value types, and if I
have to differentiate, then I lose the benefit of the pattern, and if I
don't... all I can see as a way out is Boxing...
Am I trying to do something that's impossible here?