Hi Nicholas,
If I have...
A

bject
B:A
C:A
In what way is B more incompatible with C than A is with C? Either A nor B
can be cast to C.
I don't want to make it a general rule to replace all classes with classes
that are derived from them, that might cause som problems.
What i have is a 1 to 1 mapping between specific types and types that
extends them. This mapping is made at run-time and is not known at design
time.
For a more detailed description see:
http://groups.google.se/[email protected]&frame=off
and:
http://www.codeproject.com/useritems/scripting.asp
This is somehow done in remoting. A proxy object is generated and used
instead of the real object. Can this be done in C#, or is it strictly
magic that works for things that are hard-coded into the framework?
/Hugo
Nicholas Paldino said:
Hugo,
You can't do this. It would break all sorts of things. What if you
had another type, C, which derived from A? B and C would be
incompatable, and what you are trying to do would break, big time.
What you want to do is create a class factory, which would be a method
which will create the type for you, and return a common base type.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
Hugo Wetterberg said:
Hi all,
I recently asked about how to intercept object creation and supply an
object that can be cast into the requested object.
If B extends A, when new A() is called an instance of B should be
returned.
To get an idea of what I'm trying to do and why, please read
http://www.codeproject.com/useritems/scripting.asp
/Hugo