There are numbers of general purpose extensions methods in TP:
System.StringExtensions, Tp.Utils
System.Linq.EnumerableExtensions, Tp.Utils
System.StringExtensions, Tp.Utils
string Fmt(this string format, params object[] args)
This is a shortcut for string.Format() method:
"Hi, {0}! Today is {1}".Fmt(name, DateTime,Now);
T ParseEnum<T>(this string name) bool TryParseEnum<T>(this string name, out T result)
Generic versions (exception-ful and exception-free) version of Enum.Parse.
MyEnum enumValue = "EnumValue".Parse<MyEnum>(); if ("Invalid Enum".TryParse<MyEnum>(out enumValue)) { }
System.Linq.EnumerableExtensions, Tp.Utils
string ToString<T>(this IEnumerable<T> source, string separator) string ToString(this IEnumerable source, string separator)
Similar to "string.Join(string separator, string[] array)"
string ToSqlString<T>(this IEnumerable<T> ids)
Returns either "( null )" for null or empty collection or smth like "(1,2,3)"
bool IsOrdered<T>(this IEnumerable<T> items) bool IsOrdered<T>(this IEnumerable<T> items, Comparer<T> comparer) bool IsOrdered<T>(this IEnumerable<T> items, Comparison<T> comparison)
Checks whether a collection is ordered. Versions with Comparer and Comparison are also available (for custom comparison or inverted order).
IEnumerable<T> Concat<T>(this IEnumerable<T> items, T item)
Shortcut for .Concat(new [] {item})
void ForEach<T>(this IEnumerable<T> items, Action<T> action)
Similar to List.ForEach()
IEnumerable<TResult> Zip<T1, T2, TResult>(this IEnumerable<T1> first, IEnumerable<T2> second, Func<T1,T2, TResult> selector)
See http://msdn.microsoft.com/en-us/library/dd267698%28VS.100%29.aspx
bool Empty<T>(this IEnumerable<T> enumerable) bool IsNullOrEmpty<T>(this IEnumerable<T> enumerable)
Pretty obvious.
Комментариев нет:
Отправить комментарий