[Conditional] question

From: Marc Jennings (MarcJennings_at_community.nospam)
Date: 01/10/05


Date: Mon, 10 Jan 2005 14:40:26 +0000

Hi there,

I am trying to get some conditional functionality into some of my
apps. I can use the format :

[Conditional("DEBUG")]
private void doStuff()
{
  //do something
}

as expected, but I would like to makr it a little more useful in a
multi-machine environment.

I want to make tweaks to an application based up whether it is running
on my development laptop, the stage server or the live server, and
conditionals seem to be the most efficient way forward. However, I am
not sure how to go about defining an environment variable to trigger
the consitional method.

Here's what I *think* I want to do...
> **snip unnecessary stuff**
>
> string outputMessage;
> string productionServer;
>
> private string statusMessage()
> {
> outputMessage = "This application is running on " + Environment.HostName + ". ";
> productionServer = "This is the production server. ";
> isDevBox();
> return outputMessage + productionServer;
> }
>
> [Conditional( ***HERE IS WHERE I AM COMING UNSTUCK****)]
> private void checkIsDevBox()
> {
> //reset things like connection strings, data table names, development queries, and whatever else I need
> productionServer = "This is one of the development of stage servers. ";
> }
> **snip unnecessary stuff**

It seems that I need to check if Environment.Hostname matches one of
my two development server names, and if so, set a flag that
[Conditional] can work with. It's all very well to know this is what
I need to do, but I have not the first clue about how to go about that
bit.

Can anyone help, please?

Thanks
Marc.



Relevant Pages

  • Re: Check files on 2 servers
    ... this will work on simple network: ... private void getAllFilesAndFolders(string path, string baseRoot,ref ... with the files from the other server and compare then. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: My First C# (warning - long post)
    ... public CodeStatistics(String csServerName, String csElementId) ... private void updateLocInTheCscsDatabase() ... linesOfGuiCode(clLine, ref commentStart, ref ... commentStart, ref String commentEnd, ref String commentSingle) ...
    (comp.lang.cobol)
  • Re: BeginAccept callback problem
    ... I'm trying to develop a server that listens to incoming calls using ... private void btnStart_Click ... Socket listener = ar.AsyncState; ...
    (microsoft.public.dotnet.languages.csharp)
  • C# Event Handlers For Dynamically Created DropDownLists
    ... Problem - when the user selection is extracted form the dropdownlists ... private void Page_Load ... private void btnLoadDb_Click(object sender, System.EventArgs e) ... string dbFileDestination = Path.Combine; ...
    (microsoft.public.dotnet.languages.csharp)
  • The Source Code without extraneous bits
    ... private void buttonRunProgram_Click ... private void addThreadToThreadWatch(Thread t, string ... TextWriter tmpFileWriter = new ... string strFileName; ...
    (microsoft.public.dotnet.languages.csharp)