[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.remoting

Re: Alternative to abstract class?

Ken Kolda

8/26/2004 9:34:00 PM

To solution to your problem is to use a factory pattern to create your CAOs.
In other words, have your clients retrieve an SAO from your server using
Activator.GetObject() (or by registering a well-known object). Then invoke
methods on the SAO that construct and return your CAOs, e.g.

// This is your CAO, which implements
public class MyCAO : MyCAOAbstractBase
{
public MyCAO(string s)
{
//...
}

// The implementation of your abstract base class methods goes here
}

// This is your SAO, which is a "factory" for your CAOs
public class MySAO : MySAOAbstractBase
{
public IMyCAO CreateCAO(string s)
{
return new MyCAO(s);
}
}

Now you can create your CAO's with whatever parameters are needed without
having the implementation on the client.

Ken


"f00sion" <f00sion@discussions.microsoft.com> wrote in message
news:CFB3ACC1-FD23-4727-94F2-51FB70092E06@microsoft.com...
> I found a good tutorial of how to supply the objects without having
> the implementation files on the client. This was working great until I
> realized that I couldnt use any constructors with server activated
> objects, so I switched to client activated objects only to run into
> the next roadblock, doh! can't instantiate abstract classes... here is
> a simple example of the structure, im sure there is a way to do it to
> allow instantiation but I am not as knowledgeable of inheritance as I
> should be:
>
>
> namespace JLClient
>
> {
>
> public abstract class address : MarshalByRefObject
>
> {
>
> public abstract string foo{get;set;}
>
> public abstract string test();
>
> }
>
> }
>
>
>
> namespace JLBase
>
> {
>
> public class address : JLClient.address
>
> {
>
> public override string foo{get{return _foo;}set{_foo=value}}
>
> public override string test()
>
> { return "blah"; }
>
> private string _foo;
>
> }
>
> }
>
> The goal is for the client to only have the minimum of what they need in
the
> dll, and not our full implementation. Is there a way to do it using CAO
> without abstract classes?
>