HighTechTalks DotNet Forums  

CAOs, Shared Interfaces, and Factory Pattern

Dotnet Framework (Remoting) microsoft.public.dotnet.framework.remoting


Discuss CAOs, Shared Interfaces, and Factory Pattern in the Dotnet Framework (Remoting) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Josh Collins
 
Posts: n/a

Default CAOs, Shared Interfaces, and Factory Pattern - 03-12-2007 , 01:38 PM






All, I'm trying to accomplish something very similar to the Server-
Side Factory implementation found in Rammer's "Advanced .NET
Remoting".

My requirements are as such:
- Use shared interfaces (to keep implementation off the client)
- Dynamically determine which remote object to call from factory

This is what I have:
/* Interface for Facade Factory */
public interface IRemotingFacadeManager
{
object GetFacade(Type type, ApplicationPrincipal
applicationPrincipal);
}
/* Interface for Remote Object */
public interface IRemoteFacade
{
string GetValue();
}

/* Implementation of Factory */
public class RemotingFacadeManager : MarshalByRefObject,
IRemotingFacadeManager
{
public object GetFacade(Type facadeType, ApplicationPrincipal
appPrincipal)
{
Type concreteType = GetConcreteType(facadeType);
object instanceObj =
Activator.CreateInstance(concreteType, new object[] {appPrincipal});
return instanceObj;
}
}

/* Implementation of Remote Object (BaseRemoteableFacade inherits
MBRO) */
public class RemoteFacade : BaseRemoteableFacade, IRemoteFacade
{
public string GetValue()
{
return "foo";
}
}

/* Client Implementation */
facadeManager =
Activator.GetObject(typeof(IRemotingFacadeManager) , <location>) as
IRemotingFacadeManager;
object facade = facadeManager.GetFacade(typeof(IRemoteObject),
applicationPrincipal);


My problem occurs that I get a class cast exception when casting the
facade object (transparent proxy) to an IRemoteFacade object.

Is the implementation I'm going after possible?

Thanks for any input!
Josh Collins


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.