Sorry to answer with a suggestion to do it differently, but.. If (winforms) seems like a code smell to me.
If you have a class (say an error handler), then I would suggest you allow some additional handlers to be injected at runtime by the hosting application. So instead of if (winforms) you have. //doing stuff Foreach (var handler in additionalHandlers) Handler(context); //winforms can inject an additional hander? A class library should not care what context it is running in really. If you give a bit more information am happy to suggest how you could shift the responsibility elsewhere. Regards, Jake Ginnivan Readify | Senior Developer | MVP (VSTO) M: +61 403 846 400 | E: [email protected]<mailto:[email protected]> | W: www.readify.net<http://www.readify.net/> From: [email protected] [mailto:[email protected]] On Behalf Of Anthony Mayan Sent: Wednesday, 14 September 2011 12:24 PM To: ozDotNet Subject: Re: Detect whether asp.net or winform true...have class that will take a screen shot if a windows form...ok..my question should be How do i determine if the code is running on winforms? On Wed, Sep 14, 2011 at 1:19 PM, David Kean <[email protected]<mailto:[email protected]>> wrote: What's the scenario? What if you are in a windows service, console, WPF or Windows 8 App? Sent from my Windows Phone ________________________________ From: Anthony Mayan Sent: Tuesday, September 13, 2011 8:08 PM To: ozDotNet Subject: Re: Detect whether asp.net<http://asp.net/> or winform yep..thats what i was thinking to do also...thanks On Wed, Sep 14, 2011 at 12:55 PM, Raghu Rana <[email protected]<mailto:[email protected]>> wrote: I suppose you can check in your class library if HttpContext.Current is null ? On Wed, Sep 14, 2011 at 12:52 PM, Anthony Mayan <[email protected]<mailto:[email protected]>> wrote: Is it possible to detect whether the code is runing on asp.net<http://asp.net/> or winforms from a class library? Anthony -- Raghu Rana Mobile: +61 432 139 301<tel:%2B61%20432%20139%20301> Email: [email protected]<mailto:[email protected]>
