0

Resolved

Review current extension methods and merge personal library

description

I need to review the current library and find ext. methods I have in my personal library that are not currently in this lib.

file attachments

comments

wrote May 23, 2012 at 3:35 PM

Adding To DateTimeExtensions.
 

dateObj.Yesterday() - Returns previous days date from the date specified
dateObj.Tomorrow() - Return next days date from the date specified
dateObj.ToFriendlyString() - returns a friendly date string for display such as "Today at 10:00 am", "Yesterday at 6:43 pm", "Tuesday at 5:50 am"
dateObj.EndOfDay() - Returns the date at 23:59.59.999 for the specified DateTime
dateObj.Noon() - Returns the date at 12:00:00 for the specified DateTime
dateObj.Midnight() - Returns the date at 00:00:00 for the specified DateTime. This may seem silly, but chaining allows you to do things like dateObj.EndOfDay().Tomorrow()
dateObj.IsWeekday() - Returns boolean value indicating if the day falls during the week.
*NOTE: Add unit tests

wrote May 25, 2012 at 2:37 AM

I added 62 new methods to the base extension library.  I am now starting to move to the WPF and MVC Libraries.
 
Added ColorExtensions

string ToHtmlColor(this Color color)
int ToOleColor(this Color color)
int ToWin32Color(this Color color)
Adding to ArrayExtensions

bool IsEmpty(this Array array)
Adding to EnumerableExtensions

bool HasCountOf<T>(this IEnumerable<T> source, int count)
IEnumerable<T> EnumValuesToList<T>(this IEnumerable<T> collection)
IEnumerable<string> EnumNamesToList<T>(this IEnumerable<T> collection)
Adding to CollectionExtensions

bool IsEmpty(this ICollection collection
bool IsEmpty<T>(this ICollection<T> collection)
bool IsEmpty(this IList collection)
bool IsEmpty<T>(this IList<T> collection)
Adding to DictionaryExtensions

bool IsEmpty(this IDictionary collection)
bool IsEmpty<TKey, TValue>(this IDictionary<TKey, TValue> collection)
Adding To DrawingExtensions

Bitmap ScaleToSize(this Bitmap bitmap, Size size)
Bitmap ScaleToSize(this Bitmap bitmap, int width, int height)
Bitmap ScaleProportional(this Bitmap bitmap, Size size)
Bitmap ScaleProportional(this Bitmap bitmap, int width, int height)
Bitmap ScaleToSizeProportional(this Bitmap bitmap, Size size)
Bitmap ScaleToSizeProportional(this Bitmap bitmap, Color backgroundColor, Size size)
Bitmap ScaleToSizeProportional(this Bitmap bitmap, int width, int height)
Bitmap ScaleToSizeProportional(this Bitmap bitmap, Color backgroundColor, int width, int height)
byte[] GetImageInBytes(this Image img, ImageFormat format)
string GetImageInBase64(this Image img, ImageFormat format)
Image ScaleImage(this Image img, int height, int width)
Image ResizeAndFit(this Image image, Size newSize)
Image ConvertToImage(this byte[] byteArrayIn)
Adding to DateTimeExtensions

long ToUnixEpoch(this DateTime dateTime)
Added DecimalExtensions

decimal RoundDecimalPoints(this decimal val, int decimalPoints)
decimal RoundToTwoDecimalPoints(this decimal val)
Added EventHandlerExtensions

void RaiseEvent<TEventArgs>(this EventHandler<TEventArgs> eventHandler, object sender, TEventArgs e) where TEventArgs : EventArgs
void RaiseEventOnUIThread<TEventArgs>(this EventHandler<TEventArgs> eventHandler, object sender, TEventArgs e) where TEventArgs : EventArgs
Adding to ObjectExtensions

T Cast<T>(this object o)
T Cast<T>(this object o, T defaultValue)
void CopyPropertiesFrom(this object target, object source)
void CopyPropertiesFrom(this object target, object source, string ignoreProperty)
void CopyPropertiesFrom(this object target, object source, string[] ignoreProperties)
string ToPropertiesString(this object source
string ToPropertiesString(this object source, string delimiter)
string ToXml(this object source)
string ToXml(this object source, Encoding encoding)
void ExceptionIfNullOrEmpty(this object value, string message, string name)
Addind to StringExtensions

String RemoveLeft(this String str, int number_of_characters)
String RemoveRight(this String str, int number_of_characters)
byte[] EncryptToByteArray(this String plain_text, String password)
String DecryptFromByteArray(this byte[] encrypted_bytes, String password)
String EncryptToString(this String plain_text, String password)
String DecryptFromString(this String encrypted_bytes_string, String password)
String BytesToHexString(this byte[] bytes)
byte[] HexStringToBytes(this String str)
string DefaultIfNullOrEmpty(this string s, string defaultValue)
string ExceptionIfNullOrEmpty(this string obj, string message, string name)
string JoinNotNullOrEmpty(this string[] objs, string separator)
StringDictionary ParseCommandlineParams(this string[] value)
string EncodeEmailAddress(this string emailAddress)
string GetSHA1Hash(this string stringToHash)

wrote May 25, 2012 at 3:20 AM

Added 26 extension methods to the Windows (WPF)  library
 
Adding to BitmapSourceExtensions

BitmapImage ToBitmapImage(this Bitmap bitmap)

BitmapImage ToBitmapImage(this byte[] byteArray)

BitmapSource ToBitmapSource(this byte[] byteArray)
Added ButtonExtensions

void RemoveClickEvent(this Button btn)
Added CanvasExtensions

void AddChild<T>(this Canvas canvas, T control)

void RemoveChild<T>(this Canvas canvas, T control)

void InsertChild<T>(this Canvas canvas, int index, T control)

double GetCanvasLeft<T>(T control)

double GetCanvasTop<T>(T control)

Point GetCanvasPosition<T>(T control)

void SetCanvasLeft<T>(T control, double length)

void SetCanvasTop<T>(T control, double length)

void SetCanvasPosition<T>(T control, Point value)
Added ControlExtensions

string DumpControlTemplate(this Control ctrl)
Added DispatcherExtensions

void InvokeAction(this Dispatcher dispatcher, Action action, DispatcherPriority priority) + 3 overloads
TResult InvokeAction<TResult>(this DispatcherObject source, Func<TResult> func) + 4 overloads
void InvokeAction(this DispatcherObject source, Action func) + 4 overloads
Added FrameworkElementExtensions

void BringToFront(this FrameworkElement control)
Added InteropExtensions

static bool? ShowDialog(this Window win, IntPtr handle)
Added TextboxExtensions

void SetInputScope(this TextBox tb, InputScopeNameValue inputScopeNameValue)
Adding to UIElementExtensions

void SendToFront(this UIElementCollection collection, UIElement control)
Added WindowExtensions

void SetInitialFocus(this Window window, Control focus)
Added DependencyObjectExtensions

T FindParent<T>(this DependencyObject child) where T : DependencyObject

T FindChild<T>(this DependencyObject parent, string childName) where T : DependencyObject

List<T> GetVisualChildCollection<T>(this DependencyObject parent) where T : DependencyObject

wrote May 25, 2012 at 3:35 AM

Added 1 extension method to Web Library
 
Added to ControlExtensions

void ForEachControl(this ControlCollection controlCollection, Action<Control> action)
 

wrote May 25, 2012 at 3:49 AM

Associated with changeset 69121.