Arsen,
With all due respect to the previous posters, they are wrong in their
answers. You can check the static Current property of the HttpContext
class. If it returns null, then you are not running in an ASP.NET
environment.
However, I will say this, you should at the least abstract out the
interface to access the cache/hashtable. I *think* that you can use the
ASP.NET cache in non ASP.NET situations (I don't know what makes me think
that, so don't kill me if it is not true), and if not, you could easily
generate your own cache with similar semantics.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
"Arsen V." <> wrote in message
news:...
> Hello,
>
> I have a localization class that I want to use from either Web or Windows
> Forms apps. Currently it stores some information in the HttpRuntime.Cache
> object. I want to be able to determine the current context in which the
> class is called. If it is called through ASP.NET, I want it to use the
> HttpRuntime, but if it is called through Windows Forms app, I want it to
> use
> a private static Hashtable.
>
> What is the best way for an object to determine what kind of application
> is
> calling it.
>
> Thanks,
> Arsen
>
>