Code checking for local dataportal vs. remote dataportal

Code checking for local dataportal vs. remote dataportal

Old forum URL: forums.lhotka.net/forums/t/5208.aspx


xxxJasonxxx posted on Thursday, August 07, 2008

What is the smartest way for my object/app to determine if it is currently running using a local dataportal or a remote dataportal?

I know I could find out by checking the config file, but I was wondering if CSLA has a shortcut property somewhere specifically for this purpose.

We want different code to run depending on whether it is local dataportal or remote dataportal (really the issue is whether or not the serialization is going to happen - my understanding is that in local the serialization does not happen).

rsbaker0 replied on Thursday, August 07, 2008

Here is a method I have that does it:

 

public static void NotAllowedOnClient()

{

if (ApplicationContext.DataPortalProxy != "Local" &&

ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)

{

throw new NotSupportedException("Illegal client method call with remote server portal in use");

}

}

(Off topic: Does any one know how to cut/paste code here so it looks nice?)

nermin replied on Thursday, August 07, 2008

You could use ApplicationContext.DataPortalProxy property to determine that (LocalProxy, WcfProxy,…)

 

From: xxxJasonxxx [mailto:cslanet@lhotka.net]
Sent: Thursday, August 07, 2008 3:37 PM
To: Nermin Dibek
Subject: [CSLA .NET] Code checking for local dataportal vs. remote dataportal

 

What is the smartest way for my object/app to determine if it is currently running using a local dataportal or a remote dataportal?

I know I could find out by checking the config file, but I was wondering if CSLA has a shortcut property somewhere specifically for this purpose.

 



Copyright (c) Marimer LLC