In .Net remoting, through the use of the ProxyAttribute and having objects
inherit from ContextBoundObject, it's possible to hook the "new" creation
of an object. Every time an object is created, CreateInstance of the
ProxyAttribute is called to create the object and the proxy.

This behavior is very powerful and could be useful when creating non-
remote objects. In C++ it was possible to override the "new" operator to
achieve this behavior.

Is anyone aware of a way to implement this behavior when creating objects
that I define using C#?

I would like to do something along the line of:

[MyObjectCreator]
public class MyObject
{
   public class MyObject() {...}
}

To create an object:
MyObject obj = new MyObject();

I would like MyObjectCreator be responsible for the actual creation of the
object.

In the past I would have used a factory pattern for this behavior. I was
just wondering if there was a better way using .Net.

Thanks for any info.
Chris Rolon

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to