Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Where to put extension methods?
Message
De
12/09/2012 13: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:
01552787
Vues:
38
This message has been marked as a message which has helped to the initial question of the thread.
>>>Hi everybody,
>>>
>>>I have a solution consisting of multiple projects. I found this extension method for the string proper case
>>>
>>>http://www.extensionmethod.net/Details.aspx?ID=101
>>>
>>>(I also read Rick Strahl implementation where the same method was discussed and then lots of interesting comments followed).
>>>
>>>My question is - where should I create such extension methods? In which project and hierarchy and what is the good name for such methods and should I place them all in one file?
>>>
>>>Right now I have
>>>
>>>Objects
>>>Data
>>>ConsoleApp (this is for testing only)
>>>Main Web project
>>>
>>>in my solution.
>>>
>>>I want these extension methods to be re-usable in other projects also.
>>>
>>>Thanks in advance.
>>
>>
>>Put extension methods in a separate namespace
>>
>>>I want these extension methods to be re-usable in other projects also.
>>
>>I suppose you have a common project that is used in all solutions ? If yes, put them there in a separate namespace
>
>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
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform