-
Notifications
You must be signed in to change notification settings - Fork 4
Extensions
Mark Clearwater edited this page Jun 27, 2016
·
24 revisions
Listed here are both the supported extensions, as well as a wish-list of extensions to be added over time.
- Action AsActionUsing<T1>(this Action<T1> action, T1 parameter1)
- Action AsActionUsing<T1, T2>(this Action<T1, T2> action, T1 parameter1, T2 parameter2)
- Action AsActionUsing<T1, T2, T3>(this Action<T1, T2, T3> action, T1 parameter1, T2 parameter2, T3 parameter3)
- void Clear<T>(this T[] items)
- T[] OrNullIfEmpty<T>(this T[] items)
- T[] OrEmptyIfNull<T>(this T[] items)
- string AsAString(this char[] chars)
- string AsAString(this byte[] chars)
- Action AsAction<T>(this Func<T> function)
- Action AsActionUsing<TOutput, TParameter>(this Func<TParameter, TOutput> function, TParameter parameter)
- Action AsActionUsing<TOutput, TParameter1, TParameter2>(this Func<TParameter1, TParameter2, TOutput> function, TParameter1 parameter1, TParameter2 parameter2)
- Action AsActionUsing<TOutput, TParameter1, TParameter2, TParameter3>(this Func<T1, T2, T3, TOutput> action, T1 parameter1, T2 parameter2, T3 parameter3)
- T GetValueOrDefault<T>(this T item, T defaultValue) where T : class
- bool IsNotEmpty<TItem>(this IEnumerable<TItem> items)
- bool IsNullOrEmpty<TItem>(this IEnumerable<TItem> items)
- IEnumerable<TItem> OrEmptyIfNull<TItem>(this IEnumerable<TItem> items)
- IEnumerable<TItem> OrNullIfEmpty<TItem>(this IEnumerable<TItem> items)
- void EnsureOrder(int first, int second)
- ExclusiveInteger Exclusive(this int value)
- InclusiveInteger Inclusive(this int value)
- bool IsBetween(this int value, ExclusiveInteger lowerLimit, ExclusiveInteger upperLimit)
- bool IsBetween(this int value, InclusiveInteger lowerLimit, ExclusiveInteger upperLimit)
- bool IsBetween(this int value, ExclusiveInteger lowerLimit, InclusiveInteger upperLimit)
- bool IsBetween(this int value, InclusiveInteger lowerLimit, InclusiveInteger upperLimit)
- bool IsBetween(this int value, int lowerLimit, int upperLimit)
- bool IsBetweenExclusive(this int value, int lowerLimit, int upperLimit)
Example : 5.IsBetween(2.Exclusive(), 5.Inclusive())
- void EnsureIsNotNull(this object instance)
- void EnsureIsNotNull(this object instance, string argumentName)
- bool IsNotNull(this object instance)
- bool IsNull(this object instance)
- string FormatWith(this string format, params object[] parameters)
- bool IsNotNullOrWhitespace(this String s)
- bool IsNullOrWhitespace(this String s)
- string Left(this string value, int length)
- string Right(this string value, int length)
- string SafeLeft(this string value, int length)
- string SafeRight(this string value, int length)
- string SafeToString<T>(this T item)
- string SafeToString<T>(this T item, string nullString)
- string SafeTrim(this string value)
- string SafeTrimStart(this string value)
- string SafeTrimEnd(this string value)
- string Unquoted(this string value)
- string ValueOrEmptyIfNull(this string value)
- string ValueOrEmptyIfNullOrWhitespace(this string value)
- string ValueOrIfNull(this string value, String replacement)
- string ValueOrIfNullOrWhitespace(this string value, String replacement)
- string ValueOrNullIfWhitespace(this string value)
- bool IsOfType<T>(this object item)
- T When<T>(this T item, Func<bool> predicate, Func<T,T> function)
- TResult Map<TSource, TResult>(this T item, Func<TSource, TResult> function)
- T Tee<T>(this T item, Action<T> action) //https://en.wikipedia.org/wiki/Tee_(command) alternate name Pipe?
- string[] ToLines(this string value)
- string[] ToNonBlankLines(this string value)
- string JoinWith(this IEnumerable<string> value, string delimiter)
- string JoinAsLines(this IEnumerable<string> value)
- string Unquoted(this string value)
- long NumberOfLines(this string s);
- long NumberOfNonBlankLines(this string s);
- bool IsNumeric(this string value, bool trimWhitespace = true)
- string Reverse(this string value)
- string SafeReverse(this string value)
- string SafeReplace(this string value, char oldChar, char newChar)
- string SafeReplace(this string value, string old, string new)
- string SafeToLower(this string value)
- string SafeToLower(this string value, CultureInfo culture)
- string SafeToLowerInvariant(this string value)
- string SafeToUpper(this string value)
- string SafeToUpper(this string value, CultureInfo culture)
- string SafeToUpperInvariant(this string value)
- char[] SafeToCharArray(this string value)
- bool SafeEndsWith(this string input, string value)
- bool SafeEndsWith(this string input, string value, StringComparison comparisonType)
- bool SafeEndsWith(this string input, string value, CultureInfo culture)
- bool SafeStartsWith(this string input, string value)
- bool SafeStartsWith(this string input, string value, StringComparison comparisonType)
- bool SafeStartsWith(this string input, string value, CultureInfo culture)
- string SafeSubstring(int startIndex)
- string SafeSubstring(int startIndex, int length)
- string SafePadLeft(this string input, int totalWidth)
- string SafePadLeft(this string input, int totalWidth, char paddingChar)
- string SafePadRight(this string input, int totalWidth)
- string SafePadRight(this string input, int totalWidth, char paddingChar)
- byte[] SafeToByteArray(this string input)
- char[] SafeToCharArray(this string input)
- byte[] ToByteArray(this string input)
- char[] ToCharArray(this string input)
- TimeSpan Weeks(this int value)
- TimeSpan Days(this int value)
- TimeSpan Hours(this int value)
- TimeSpan Minutes(this int value)
- TimeSpan Seconds(this int value)
- TimeSpan Milliseconds(this int value)
- YearSpan Years(this int value)
- DateTime Ago(this YearSpan interval)
- DateTime FromNow(this YearSpan interval)
- DateTime Before(this YearSpan interval, DateTime origin)
- DateTime Since(this YearSpan interval, DateTime origin)
- (operators + - with DateTime)
- MonthSpan Months(this int value)
- DateTime Ago(this MonthSpan interval)
- DateTime FromNow(this MonthSpan interval)
- DateTime Before(this MonthSpan interval, DateTime origin)
- DateTime Since(this MonthSpan interval, DateTime origin)
- (operators + - with DateTime)
- DateTime Ago(this TimeSpan interval)
- DateTime FromNow(this TimeSpan interval)
- DateTime Before(this TimeSpan interval, DateTime origin)
- DateTime Since(this TimeSpan interval, DateTime origin)
- IEnumerable<T> AsEnumerable(this ICollection<T> collection)
- void AddRange<T>(this ICollection<T> collection, IEnumerable<T> itemsToAppend)
- ICollection<T> RemoveEach<T>(this ICollection<T> collection)
- ICollection<T> RemoveEach<T>(this ICollection<T> collection, Func<T, bool> whereExpression)
- ICollection<T> RemoveEach<T>(this ICollection<T> collection, Func<T, int, bool> whereExpression)
- ICollection<T> RemoveEachInReverse<T>(this ICollection<T> collection)
- ICollection<T> RemoveEachInReverse<T>(this ICollection<T> collection, Func<T, bool> whereExpression)
- ICollection<T> RemoveEachInReverse<T>(this ICollection<T> collection, Func<T, int, bool> whereExpression)
- ICollection<T> OrNullIfEmpty(this ICollection<T> collection)
- ICollection<T> OrEmptyIfNull(this ICollection<T> collection)
- IEnumerable<T> AsEnumerable(this IList<T> collection)
- IList<T> RemoveEach<T>(this IList<T> items)
- IList<T> RemoveEach<T>(this IList<T> items, Func<T, bool> whereExpression)
- IList<T> RemoveEach<T>(this IList<T> items, Func<T, int, bool> whereExpression)
- IList<T> RemoveEachInReverse<T>(this IList<T> items)
- IList<T> RemoveEachInReverse<T>(this IList<T> items, Func<T, bool> whereExpression)
- IList<T> RemoveEachInReverse<T>(this IList<T> items, Func<T, int, bool> whereExpression)
- IList<T> RemoveEachByIndex<T>(this IList<T> items)
- IList<T> RemoveEachByIndex<T>(this IList<T> items, Func<T, bool> whereExpression)
- IList<T> RemoveEachByIndex<T>(this IList<T> items, Func<T, int, bool> whereExpression)
- IList<T> RemoveEachByIndexInReverse<T>(this IList<T> items)
- IList<T> RemoveEachByIndexInReverse<T>(this IList<T> items, Func<T, bool> whereExpression)
- IList<T> RemoveEachByIndexInReverse<T>(this IList<T> items, Func<T, int, bool> whereExpression)
- IList<T> OrNullIfEmpty(this IList<T> items)
- IList<T> OrEmptyIfNull(this IList<T> items)
- ReadOnlyCollection<T> ToReadOnlyCollection<T>(this IList<T> items)
- ReadOnlyCollection<T> SafeToReadOnlyCollection<T>(this IList<T> items)
- List<T> RemoveEach<T>(this List<T> items)
- List<T> RemoveEach<T>(this List<T> items, Func<T, bool> whereExpression)
- List<T> RemoveEach<T>(this List<T> items, Func<T, int, bool> whereExpression)
- List<T> RemoveEachInReverse<T>(this List<T> items)
- List<T> RemoveEachInReverse<T>(this List<T> items, Func<T, bool> whereExpression)
- List<T> RemoveEachInReverse<T>(this List<T> items, Func<T, int, bool> whereExpression)
- List<T> RemoveEachByIndex<T>(this List<T> items)
- List<T> RemoveEachByIndex<T>(this List<T> items, Func<T, bool> whereExpression)
- List<T> RemoveEachByIndex<T>(this List<T> items, Func<T, int, bool> whereExpression)
- List<T> RemoveEachByIndexInReverse<T>(this List<T> items)
- List<T> RemoveEachByIndexInReverse<T>(this List<T> items, Func<T, bool> whereExpression)
- List<T> RemoveEachByIndexInReverse<T>(this List<T> items, Func<T, int, bool> whereExpression)
- List<T> OrNullIfEmpty(this List<T> items)
- List<T> OrEmptyIfNull(this List<T> items)
- void Foreach<T>(this IEnumerable items, Action<T> action)
- IEnumerable<T> TakeWhile<T>(this IEnumerable<T> source, Func<T, bool> predicate)
- IEnumerable<T> TakeWhile<T>(this IEnumerable<T> source, Func<T, int, bool> predicate)
- IEnumerable<T> SkipUntil<T>(this IEnumerable<T> source, Func<T, bool> predicate)
- IEnumerable<T> SkipUntil<T>(this IEnumerable<T> source, Func<T, int, bool> predicate)
- IEnumerable<T> TakeUntil<T>(this IEnumerable<T> source, Func<T, bool> predicate)
- IEnumerable<T> TakeUntil<T>(this IEnumerable<T> source, Func<T, int, bool> predicate)
- IEnumerable<T> Pipe<T>(this IEnumerable items, Action action)
- IEnumerable<T> FullOuterJoin<TLeft, TRight, TKey, TResult>(this IEnumerable<TLeft> left, IEnumerable<TRight>, Func<TLeft, TKey> leftKeySelector, Func<TRight, TKey> rightKeySelector, Func<TLeft, TRight> resultSelector)
- List<T> ToListOf<T>(this IEnumerable items)
- List<T> SafeToListOf<T>(this IEnumerable items)
- List<T> SafeToList<T>(this IEnumerable<T> items)
- T[] SafeToArray<T>(this IEnumerable<T> items)
- Dictionary<TKey, TItem> SafeToDictionary<TItem, TKey>(this IEnumerable<T> items, Func<TItem, TKey> keySelector)
- HashSet<T> SafeToHashSet<T>(this IEnumerable<T> items)
- HashSet<T> SafeToHashSet<T>(this IEnumerable<T> items, IEqualityComparer<T> equalityComparer)
- IEnumerable<T> Slice<T>(this IEnumerable<T> items, int start, int end)(like python's list[x:y] slice functionality)
- ReadOnlyCollection<T> ToReadOnlyCollection<T>(this IEnumerable<T> items)
- ReadOnlyCollection<T> SafeToReadOnlyCollection<T>(this IEnumerable<T> items)
- ObservableCollection<T> ToObservableCollection<T>(this IEnumerable<T> items) (is ObservableCollection in the PCL scope?)
- ObservableCollection<T> SafeToObservableCollection<T>(this IEnumerable<T> items) (is ObservableCollection in the PCL scope?)
- Dictionary<TKey, TValue> OrNullIfEmpty(this Dictionary<TKey, TValue> dictionary)
- Dictionary<TKey, TValue> OrEmptyIfNull(this Dictionary<TKey, TValue> dictionary)
- T GetValueOrDefault<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key) where TValue : struct
- T GetValueOrDefault<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key, TValue defaultValue)
- bool DerivesFrom<Type>(this object item) where T : class
- bool IsNullable(this Type itemType)
- IEnumerable<Type> SafeGetTypes(this Assembly assembly)
- T GetAttribute<Type>(this Assembly assembly) where T: Attribute
- T SafeGetAttribute<Type>(this Assembly assembly) where T: Attribute
- void EnsureIsEnum<T>() where T : struct, IComparable, IConvertible, IFormattable
- bool IsEnum<T>() where T : struct, IComparable, IConvertible, IFormattable
- void EnsureIsEnum(this object enumerationValue)
- bool IsEnum(this object enumerationValue)
- string GetEnumDescription<T>(T value) where T : struct, IComparable, IConvertible, IFormattable
- bool IsBetween(this long value, long lowerLimit, long upperLimit)
- bool IsBetweenExclusive(this long value, long lowerLimit, long upperLimit)
- bool IsBetween(this long value, ExclusiveLongInteger lowerLimit, ExclusiveLongInteger upperLimit)
- bool IsBetween(this long value, InclusiveLongInteger lowerLimit, ExclusiveLongInteger upperLimit)
- bool IsBetween(this long value, ExclusiveLongInteger lowerLimit, InclusiveLongInteger upperLimit)
- bool IsBetween(this long value, InclusiveLongInteger lowerLimit, InclusiveLongInteger upperLimit)
- InclusiveLongInteger Inclusive(this long value)
- ExclusiveLongInteger Exclusive(this long value)
Example: 5.IsBetween(2.Exclusive(), 5.Inclusive())
- bool IsBetween(this decimal value, decimal lowerLimit, decimal upperLimit)
- bool IsBetweenExclusive(this decimal value, decimal lowerLimit, decimal upperLimit)
- bool IsBetween(this decimal value, ExclusiveDecimal lowerLimit, ExclusiveDecimal upperLimit)
- bool IsBetween(this decimal value, InclusiveDecimal lowerLimit, ExclusiveDecimal upperLimit)
- bool IsBetween(this decimal value, ExclusiveDecimal lowerLimit, InclusiveDecimal upperLimit)
- bool IsBetween(this decimal value, InclusiveDecimal lowerLimit, InclusiveDecimal upperLimit)
- InclusiveDecimal Inclusive(this decimal value)
- ExclusiveDecimal Exclusive(this decimal value)
Example: (5m).IsBetween((2m).Exclusive(), (5m).Inclusive())
- Action AsActionUsing<T1, T2, T3, T4, TResult>(this Func<T1, T2, T3, T4, TResult> action, T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4)
- Action AsActionUsing<T1, T2, T3, T4, T5, TResult>(this Func<T1, T2, T3, T4, T5, TResult> action, T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5)
- Action AsActionUsing<T1, T2, T3, T4, T5, T6, TResult>(this Func<T1, T2, T3, T4, T5, T6, TResult> action, T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6)
- Action AsActionUsing<T1, T2, T3, T4, T5, T6, T7, TResult>(this Func<T1, T2, T3, T4, T5, T6, T7, TResult> action, T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6, T7 parameter7)
- Action AsActionUsing<T1, T2, T3, T4, T5, T6, T7, T8, TResult>(this Func<T1, T2, T3, T4, T5, T6, T7, T8, TResult> action, T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6, T7 parameter7, T8 parameter8)
- Action AsActionUsing<T1, T2, T3, T4>(this Action<T1, T2, T3, T4> action, T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4)
- Action AsActionUsing<T1, T2, T3, T4, T5>(this Action<T1, T2, T3, T4, T5> action, T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5)
- Action AsActionUsing<T1, T2, T3, T4, T5, T6>(this Action<T1, T2, T3, T4, T5, T6> action, T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6)
- Action AsActionUsing<T1, T2, T3, T4, T5, T6, T7>(this Action<T1, T2, T3, T4, T5, T6, T7> action, T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6, T7 parameter7)
- Action AsActionUsing<T1, T2, T3, T4, T5, T6, T7, T8>(this Action<T1, T2, T3, T4, T5, T6, T7, T8> action, T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, T5 parameter5, T6 parameter6, T7 parameter7, T8 parameter8)
- string GetMemberName<TExpressionBody>(this Expression<TExpressionBody> expression)
Example: ExpressionExtensions.GetMemberName(() => MyProperty)
Build implementation of ContractAnnotation- Build *.ExternalAnnotations.xml for ReSharper support
- Build Roslyn checker for extensions - with auto reformatting