web 2.0

Useful Method Extensions, Sb2.Extensions v.1.0 Released

Hi !

Here is my first release of Sb2.Extensions which refers to the following articles :

Actually the Release v.1.0 is composed in 8 parts as the following :

Cache Extensions:

Add an Item to Cache (Generic)

public static void SetInCache<T>(this Cache cache, String Key, T o)

Get an Item from Cache (Generic)

public static T GetFromCache<T>(this Cache cache, String Key)

 

Collection Extensions :

Add object to the dictionnary and which allow not only unique Keys but also unique Values

public static void Add<TKey, TValue>(this IDictionary<TKey, TValue> dic, TKey key, TValue value)

Check if the Collection is NullOrEmpty like String.IsNullOrEmpty

public static Boolean IsNullOrEmpty(this IEnumerable col)

 

Compression Extensions :

Compress specified byte array using Deflate Compression

public static byte[] Compress(this byte[] data)

Decompress the specified byte array using Deflate Compression

public static byte[] Decompress(this byte[] data)

Compress a generic object to byte array using Deflate Compression

public static byte[] Compress<T>(this T data

Decompress a generic object to byte array using Deflate Compression

public static T Decompress<T>(this byte[] compressedData) where T : class

 

Image Extensions :

Get an Image as Bitmap from Bytes

public static Bitmap FromBytes(this Bitmap value, Byte[] imageBytes)

Get Bytes from an Image

public static Byte[] GetBytes(this Bitmap value, ImageFormat format)

 

Nullable Extensions :

Convert a String value to any other type

public static T? ConvertTo<T>(this string input) where T : struct

Convert a String value to any other type with IFormatProvider

public static T? ConvertTo<T>(this string input, IFormatProvider provider) where T : struct

 

Reflection Extensions :

Invoke a Method from a Generic Object

public static T InvokeMethod<T>(this object obj, string methodName)

Invoke a Method from a Generic Object with Parameters

public static T InvokeMethod<T>(this object obj, string methodName, object[] args)

 

Session Extensions :

Compress a Generic Object using Deflate Compression and store it in the Session of the Current HttpContext

public static void SetInSession<T>(this HttpSessionState session, String Key, T o)

Decompress a Generic Object from the Current HttpContext Session

public static T GetFromSession<T>(this HttpSessionState session, String Key)

 

Text Extensions :

Dump a String to a File

public static void ToFile(this String values, FileInfo fileInfo)

Dump a String Collection to a File

public static void ToFile(this IEnumerable<String> values, FileInfo fileInfo)

Delete all files of a Directory

public static void DeleteFiles(this DirectoryInfo di)

Find  the specified String in File

public static String[] Find(this FileInfo File, String SearchPattern)

Remove all illegal Characters (Useful for URL Rewriting)

public static String RemoveIllegalCharacters(this String values)

Remove all Extra Hyphens

public static String RemoveExtraHyphen(this String values)

Remove diacritics

public static String RemoveDiacritics(this String values)

 

Hope this first release of my Extension Library help's

Thanks in advance for feedbacks.

Sb2.Extensions.rar (10,57 kb)



Views(1690)

kick it on DotNetKicks.com

Share/Save/Bookmark Subscribe

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

C#

Comments

Technorati Profile