Re: [Conditional] question
From: Ignacio Machin \( .NET/ C# MVP \) ("Ignacio)
Date: 01/10/05
- Next message: Nicholas Paldino [.NET/C# MVP]: "Re: does system.web.mail internally use CDO's??"
- Previous message: Nick Malik [Microsoft]: "Re: What interface for "ISet""
- In reply to: Marc Jennings: "[Conditional] question"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 10 Jan 2005 10:05:10 -0500
Hi,
I dont think that will work, you are detecting the environment at runtime,
the conditionals are evaluated at compile time.
A possible solution would be define a preprocessor in the project
configuration, if you have a different project definition file in each
machine you can do what yuoui want, how factible this is would depend of
your project, if you add a new file or a new reference to one of the
projects you will need to do the same thing in the others, that is the only
( HUGE ) drawback I see. you can copy the source code though.
It probably is not a solution but may be a work around, it's the best I can
think of right now.
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Marc Jennings" <MarcJennings@community.nospam> wrote in message
news:p745u05eq7lb92iapt3loivsacpv3gh05e@4ax.com...
> 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.
- Next message: Nicholas Paldino [.NET/C# MVP]: "Re: does system.web.mail internally use CDO's??"
- Previous message: Nick Malik [Microsoft]: "Re: What interface for "ISet""
- In reply to: Marc Jennings: "[Conditional] question"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|