Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Where to put extension methods?
Message
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:
01552826
Vues:
61
This message has been marked as the solution to the initial question of the thread.
If you have reusable code that you think you're going to use in many projects it's best to create a separate project and park that functionality there. You can then break things down by functionality into different namespaces if you have a lot of functionality or keep it all under a single namespace.

For utility functions and extension methods it's often good to put everything into static classes so its easily accessible as 'one-liners'.

Personally I'm not a huge fan of extension methods because they're difficult to discover. Unless the namespace is added you can't easily find extension methods. Static methods at least are simply available via their full .NET namespace.type path.

Over the years I've built up a lot of utility functionality that I use in just about any project I work on which is published as the West Wind Web and AJAX Toolkit. Although the name has Web/AJAX in it there's a non-Web library in there called Westwind.Utilities which is sort of my hodgepodge of utility features that I use regularily in any kind of project Web and otherwise. You can check it out here if you want to get some ideas (or consider using the library for yourself - it's quite small for the all the functionality it has):

Source Code for Westwind.Utilities library:
http://www.west-wind.com:8080/svn/WestwindWebToolkit/trunk/Westwind.Utilities/

The ProperCase function would be found under StringUtils.cs for example:
http://goo.gl/DKt7O (syntax colored for easier readability - Search for proper case)

Web Toolkit Product Url:
http://www.west-wind.com/WestwindWebToolkit/

+++ Rick ---

>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.
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform