Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Where to put extension methods?
Message
De
12/09/2012 14:07:09
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01552781
Message ID:
01552791
Vues:
38
This message has been marked as a message which has helped to the initial question of the thread.
J'aime (1)
>>>Not yet. I think I need to discuss this with my colleagues before I'll proceed. But just for the reference, can you tell me how you have such things organized? Say, do you create a class library project in some common directory and have
>>>StringExtensions
>>>MathExtensions (for example)
>>>
>>>or just to give me an idea.
>>>
>>>Thanks again.
>>
>>
>>As Viv mentions - create a project with just extension methods if necessary
>>
>>I have a class per functionality
>>
>>
>>   ExtensionMethods 
>>       Arithmetic.cs   ( from Bill Clinton)
>>       BitOperations.cs
>>       Comparison.cs      ( eg  IsBetween() and InList() )
>>       Conversion.cs
>>
>>
>>But you are free to organize them as you like
>
>Thanks, will proceed in this direction after discussing it with colleagues as we may already have common stuff.


Right, and


(1) Put them in a separate namespace - you are then at liberty to turn them on/off for any specific class

(2) To avoid name clashes with classes in other namespaces, prefix the class names, eg

>> ExtensionMethods_Arithmetic.cs ( from Bill Clinton)
>> ExtensionMethods_ BitOperations.cs
>> ExtensionMethods_Comparison.cs ( eg IsBetween() and InList() )
>> ExtensionMethods_ Conversion.cs
Gregory
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform