Extension Methods from James Michael Hare (BlackRabbitCoder)
-
ToDictionary() - for enumerations of groupings
Converts an IEnumerable<IGrouping<TKey,TValue>> to a Dictionary<TKey,List<TValue>> so that you can easily convert the results of a GroupBy clause to a Dictionary of Groupings. The out-of-the-box ToDictionary() LINQ extension methods require a key and element extractor which are largely redundant when being applied to an enumeration of groupings, so this is a short-cut.
-
Mask
A set of extension methods that make it easy to mask a string (to protect account numbers or other personal data). For example, you could mask a SSN of 123456789 to be ******789.
-
TakeUntil
The opposite of TakeWhile, inverts the expression and passes to TakeWhile so that instead of taking while an expression is true, you take until an expression is true.
-
GetAttribute
Gets the first assembly attribute of the specified type from the assembly it is called from.
-
IsNullable
Returns true if the type it is called upon is a System.Nullable<> wrapped type.
-
IsDefault
Returns true if the object it is called upon is the default of its type. This will be null for referece types, zero for integer types, and a default-initialized struct for structs.
-
ToDictionary()
Converts an IEnumerable<IGrouping<TKey,TValue>> from a GroupBy() clause to a Dictionary<TKey, List<TValue>>.
-
Repeat
Repeats a character a given number of times, a little cleaner shortcut than using the string constructor.
-
GetAttributes
Gets an enumeration of assembly attributes of the specified type from the assembly it is called from.