using System; using System.Collections.Generic; using System.Linq.Expressions; using System.Reflection; namespace MiscUtil.Reflection { /// <summary> /// Generic class which copies to its target type from a source /// type specified in the Copy method. The types are specified /// separately to take advantage of type inference on generic /// method arguments. /// </summary> public static class PropertyCopy<TTarget> where TTarget : class, new()… Read more →
Category: extensionmethods
Method Injection with Simple Injector
In this post I will outline a trick I created while experimenting with the code for my post Managing Commands and Queries. If you are unfamiliar with these two patterns then please see these posts here and here for a great introduction. For the remainder of this post I will assume you have fully subscribed to the idea of parameter… Read more →
String to byte[]
public static byte[] ToByteArray(this string str) { UTF8Encoding encoding = new UTF8Encoding(); return encoding.GetBytes(str); } Read more →
You’ve got to love extension methods
public static class Roundings { public static decimal To2Dp(this decimal amount) { return Math.Round(amount, 2); } public static decimal To5Dp(this decimal amount) { return Math.Round(amount, 5); } public static decimal To6Dp(this decimal amount) { return Math.Round(amount, 6); } } Read more →