Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Global Objects
Message
De
02/09/2007 14:24:57
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Divers
Thread ID:
01251812
Message ID:
01251914
Vues:
12
>Statics are basically global instances with values that persist for the lifetime of an application.
>
>A good approach that I use in every app is that I have an App class in every project that has a number of static instance variables hanging off of it. So anything 'application-wide' usually hangs off this object.
>
>So I can go to say App.Configuration.ApplicationName or App.Configuration.ConnectionString from anywhere in the app. I have App.Constants any static hashtables and collection data that is frequently reused and doesn't need to be reloaded from the database etc. all that stuff lives off this App object as static data. Basically a static constructor (or field assignment which is bascially the same thing) makes sure the data gets loaded only on first access of the static class - after that all the data is read only or write rarely - otherwise you need to be careful about multi-threading issues.
>
>If Configuration is what you're after you should maybe check out an article I wrote a few years back for a generic configuration class for .NET that handles this all for you - you create a class and simply add properties and it reads and writes the configuration settings in various stores including config files.
>
>http://www.west-wind.com/presentations/configurationclass/configurationclass.asp
>
>Couldn't live without that class in any of my applications today...
>
>+++ Rick ---
>
>
>>Something I'm not quite understanding about C# and .NET
>>
>>Lets say... your app has a class that goes out and let's say reads all the config info for your application, and stores it internally.
>>
>>I wouldn't think that you would want to create a new instance of that class and reread the data each time, I would just want to be able to access the data from memory when needed.
>>
>>Sort of the equivalent of the application object in VFP.
>>
>>So... how would you normally go about that? (Or don't you?)
>>
>>Is there a way to get a pointer to the object that contains main?

Cool that is exactly what I am working on!

Thanks!!!!!!!!!!!!
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform