Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Custom Attributes
Message
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Custom Attributes
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Divers
Thread ID:
01400582
Message ID:
01400582
Vues:
110
Hello All, I have a method in my App class called GetText, this function accepts a string as input param, and returns a corresponding string value from a lookup table, the table has two fields, KeyName and KeyValue, my concern is , as and when I add more methods and classes that will utilise this function I have to remember to add records to the the underlying lookup table on the "live" server

e.g.
string MethodOneInSomeClass()
{
    return App.GetText("GetSiteName")
}
in this case I have to add
KeyName             KeyValue
"GetSiteName"     "London"
to the lookup table, I got bitten by this recently ( i.e. forgot to add the record ) and am trying to think of a way to avoid doing so in the future - one way I've thought might be ok, is, decorate all the methods that use the function with a custom attribute, e.g.
[GetTextAttribute("GetSiteName")]
string MethodOneInSomeClass()
{
    return App.GetText("GetSiteName")
}
and in the app use Reflection to list all attributes of type "GetTextAttribute" that are not present in the lookup table. Does this seem a reasonable approach ?
Regards,
Peter J. Kane



Pete
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform