Is this safe?

J

JezB

I have a static class that is instantiated once on Application_Start in
global.asax :-

protected void Application_Start(Object sender, EventArgs e)
{
int dialectID = 1;
Dialect.SetDialect(dialectID);
}

The static Dialect class is defined:

public class Dialect
{
public static int DialectID;
public static Placeholders Placeholders; // reference to Placeholders
class

public static void SetDialect(int dialectID)
{
DialectID = dialectID;
Placeholders = new Placeholders(DialectID);
}
//etc
}

The Placeholder class constructor fetches some data from a database and
stores it in a HybridDictionary. I want this data to only be fetched once
per user sesison and always available to all webform pages through the
Dialect class. I have tried this code and it all works but I have started to
wonder how? I have taken no steps to store either the Placeholders class nor
the Dialect class in Session or Application state, but it always seems to be
available. Is this by virtue of the Dialect class being static ?

Is this a safe and efficient way to do this ?
 
J

JezB

Incidentally, the data IS only fetched once, I get at the data via other
exposed methods in the Placeholders class, eg
Dialect.Placeholders.Expand(lookUpKey);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top