I am an ASP.NET C# web developer.
The architecture followed is 3 layer The layers used are 1. UI 2. BLL (Sometimes Communicating with BLL is done using WebServices) 3. DAL Pretty basic stuff.What I would really like to have is a BLL.Common class in the BusinessLogics.
Here I would like to use some useful extensions and helper functions that we use in almost all applicat开发者_StackOverflow社区ions. An example will IsNullOrEmpty extension.Which are the helper functions most commonly used by developers?
It would be better if I could get a list.Regards,
NaveenThere are sooo many. Lets see (some (very few) from one of my reusable libs):
Generic Utils:
- public static bool AreEqual(object val1, object val2)
- public static bool IsNumber(string val, bool integerOnly, bool positiveOnly)
Reflection Utils:
- public static object Activate(string typeName)
- public static PropertyInfo Property(Type t, string prop)
- public static void SetValueSafe(string path, object target, object val) // Converts type to appropriate. Great for auto generated UIs
- public static object ConvertType(Type expectedType, object val)
- public static object GetValue(object target, string fullPath) // Allow dot expression
Logger Utils:
- Easy to use wrapper for log4net is a great help
File Utils: // Note all of these have to use streams safely (dispose them)
- public static void WriteFileContents(string filename, Stream contentStream)
- public static byte[] GetStreamContents(Stream stream)
- public static string GetTextFileContents(string file)
- public static void WriteFileContents(string filename, byte[] contents)
- public static void AssertDirIsReadWrite(string fileOrDir, bool attemptCreate)
- public static string GetZipFileTextContents(string file)
- public static void ZipFile(string file, string zipFile)
- public static void ZipFiles(string directory, string filter, string zipFile)
- public static string FindFileInDirectory(string file, string baseDirectory)
- public static void CopyDirectory(DirectoryInfo from, DirectoryInfo target)
- public static void ClearDirectory(DirectoryInfo dir)
- public static IEnumerable GetDirectories(string baseDir)
- public static IEnumerable GetFiles(string baseDir, string ext) // Recursive
Colleciton Utils:
- Add support for Linq like methods in non generic IEnumerable
- public static void ForEach(IEnumerable e, Action action) // This one is great!
- AreEqual
- ToString
- Cast
- IsNullOrEmptySort
精彩评论