Class Utils
- Namespace
- Common
- Assembly
- Lykke.Common.dll
public static class Utils
- Inheritance
-
Utils
- Inherited Members
Fields
IsoDateMask
public const string IsoDateMask = "yyyy-MM-dd"
Field Value
IsoDateTimeMask
public const string IsoDateTimeMask = "yyyy-MM-dd HH:mm:ss"
Field Value
RussianDateMask
public const string RussianDateMask = "dd.MM.yyyy"
Field Value
Methods
AreSame(List<byte>, byte[], int)
Check the equality of two sequences starting from the specified index of the first.
public static bool AreSame(List<byte> src, byte[] search, int indexOf)
Parameters
src
List<byte>The string where to search.
search
byte[]The string which to look for.
indexOf
intThe index in src string to start searching from.
Returns
Base64ToString(string)
public static string Base64ToString(this string src)
Parameters
src
string
Returns
ByteToHex(byte)
public static string ByteToHex(byte src)
Parameters
src
byte
Returns
CloneDictionary<TKey, TValue>(Dictionary<TKey, TValue>)
[Obsolete("Use Dictionary constructor")]
public static Dictionary<TKey, TValue> CloneDictionary<TKey, TValue>(this Dictionary<TKey, TValue> src)
Parameters
src
Dictionary<TKey, TValue>
Returns
- Dictionary<TKey, TValue>
Type Parameters
TKey
TValue
CloneDoubleDictionary<TKey, TKey2, TValue>(Dictionary<TKey, Dictionary<TKey2, TValue>>)
public static Dictionary<TKey, Dictionary<TKey2, TValue>> CloneDoubleDictionary<TKey, TKey2, TValue>(this Dictionary<TKey, Dictionary<TKey2, TValue>> src)
Parameters
src
Dictionary<TKey, Dictionary<TKey2, TValue>>
Returns
- Dictionary<TKey, Dictionary<TKey2, TValue>>
Type Parameters
TKey
TKey2
TValue
CombineString(IEnumerable<string>, char)
public static string CombineString(IEnumerable<string> strings, char separator)
Parameters
strings
IEnumerable<string>separator
char
Returns
CutFrom<T>(IEnumerable<T>, int, int)
[Obsolete("Use MoreLinq Slice extension method")]
public static IEnumerable<T> CutFrom<T>(this IEnumerable<T> src, int from, int length)
Parameters
src
IEnumerable<T>from
intlength
int
Returns
- IEnumerable<T>
Type Parameters
T
Enumerate<T>()
public static IEnumerable<T> Enumerate<T>()
Returns
- IEnumerable<T>
Type Parameters
T
GenderAmount(int, string, string, string)
public static string GenderAmount(int amount, string oneWord, string twoWord, string fiveOrZerosWord)
Parameters
Returns
GenerateInts(int, int)
[Obsolete("Use Enumerable Range method")]
public static IEnumerable<int> GenerateInts(int from, int to)
Parameters
Returns
GeneratePassword()
public static string GeneratePassword()
Returns
GenerateRandomBytes(int)
public static byte[] GenerateRandomBytes(int length)
Parameters
length
int
Returns
- byte[]
GenerateYearsTillNow(int)
public static int[] GenerateYearsTillNow(int fromYear)
Parameters
fromYear
int
Returns
- int[]
GetChangesInPercents(double, double)
public static double? GetChangesInPercents(double firstVal, double secondVal)
Parameters
Returns
GetFixedAsString(decimal, int)
Formating float as string with fixed accuracy and '.' as separate
public static string GetFixedAsString(this decimal value, int accuracy)
Parameters
Returns
GetFixedAsString(double, int)
Formating float as string with fixed accuracy and '.' as separate
public static string GetFixedAsString(this double value, int accuracy)
Parameters
Returns
GetNextDateByDayOfTheWeek(DateTime, DayOfWeek)
Get the nearest date (in future) for the specified day of week, counting from the current date.
public static DateTime GetNextDateByDayOfTheWeek(DateTime nowDateTime, DayOfWeek dayOfWeek)
Parameters
Returns
HexToArray(string)
public static byte[] HexToArray(string src)
Parameters
src
string
Returns
- byte[]
HexToByte(string)
public static byte HexToByte(string src)
Parameters
src
string
Returns
HexToString(string)
public static string HexToString(string value)
Parameters
value
string
Returns
IndexOf(List<byte>, byte[])
public static int IndexOf(this List<byte> src, byte[] search)
Parameters
Returns
IsSimpleType(Type)
public static bool IsSimpleType(this Type type)
Parameters
type
Type
Returns
Limit<T>(IEnumerable<T>, int)
[Obsolete("Use Enumerable Take method")]
public static IEnumerable<T> Limit<T>(this IEnumerable<T> src, int limit)
Parameters
src
IEnumerable<T>limit
int
Returns
- IEnumerable<T>
Type Parameters
T
ListsAreSame<T>(T[], T[], Func<T, T, bool>)
public static bool ListsAreSame<T>(T[] oldOne, T[] newOne, Func<T, T, bool> equal)
Parameters
Returns
Type Parameters
T
LogPartFromStream(ILog, Stream, string, string, Exception)
public static Task LogPartFromStream(this ILog log, Stream stream, string component, string process, Exception ex)
Parameters
Returns
Map(IEnumerable<double>, double?, double?, double?, double?)
public static IEnumerable<double> Map(this IEnumerable<double> values, double? minFrom = null, double? maxFrom = null, double? minTo = null, double? maxTo = null)
Parameters
Returns
Map(double, double, double, double, double)
public static double Map(this double value, double minFrom, double maxFrom, double minTo, double maxTo)
Parameters
Returns
Mod10Check(string)
public static bool Mod10Check(string creditCardNumber)
Parameters
creditCardNumber
string
Returns
NumberToWords(int)
public static string NumberToWords(int number)
Parameters
number
int
Returns
NumberToWordsRus(int, bool)
public static string NumberToWordsRus(int amount, bool ismale)
Parameters
Returns
ParamsToString(object)
public static string ParamsToString(object obj)
Parameters
obj
object
Returns
ParseAnyDecimal(string)
public static decimal ParseAnyDecimal(this string amount)
Parameters
amount
string
Returns
ParseAnyDecimalOrDefault(string, decimal)
public static decimal ParseAnyDecimalOrDefault(this string amount, decimal defaultValue)
Parameters
Returns
ParseAnyDouble(string)
public static double ParseAnyDouble(this string amount)
Parameters
amount
string
Returns
ParseAnyDoubleOrDefault(string, double)
public static double ParseAnyDoubleOrDefault(this string amount, double defaultValue)
Parameters
Returns
ParseEnum<T>(string)
public static T ParseEnum<T>(this string value)
Parameters
value
string
Returns
- T
Type Parameters
T
ParseEnum<T>(string, T)
public static T ParseEnum<T>(this string value, T defaultValue)
Parameters
value
stringdefaultValue
T
Returns
- T
Type Parameters
T
ParseIntOrDefault(string, int)
public static int ParseIntOrDefault(this string amount, int defaultValue)
Parameters
Returns
ParseIpEndPoint(string)
public static IPEndPoint ParseIpEndPoint(this string src)
Parameters
src
string
Returns
PutLastSymbol(string, char)
public static string PutLastSymbol(string src, char symbol)
Parameters
Returns
SetNewTime(DateTime, string)
public static DateTime SetNewTime(DateTime dateTime, string time)
Parameters
Returns
SkipEvenly<T>(IEnumerable<T>, int)
public static IEnumerable<T> SkipEvenly<T>(this IEnumerable<T> initialEnumerable, int newSize)
Parameters
initialEnumerable
IEnumerable<T>newSize
int
Returns
- IEnumerable<T>
Type Parameters
T
StringToHex(string)
public static string StringToHex(this string src)
Parameters
src
string
Returns
ToBase64(byte[])
public static string ToBase64(this byte[] src)
Parameters
src
byte[]
Returns
ToBase64(string)
public static string ToBase64(this string src)
Parameters
src
string
Returns
ToByte(bool)
public static byte ToByte(this bool src)
Parameters
src
bool
Returns
ToBytes(Stream)
public static byte[] ToBytes(this Stream src)
Parameters
src
Stream
Returns
- byte[]
ToBytesAsync(Stream)
public static Task<byte[]> ToBytesAsync(this Stream src)
Parameters
src
Stream
Returns
ToChunks<T>(IEnumerable<T>, int)
[Obsolete("Use MoreLinq Batch extension method")]
public static IEnumerable<IEnumerable<T>> ToChunks<T>(this IEnumerable<T> src, int chunkSize)
Parameters
src
IEnumerable<T>chunkSize
int
Returns
Type Parameters
T
ToHexString(ICollection<byte>)
public static string ToHexString(this ICollection<byte> src)
Parameters
src
ICollection<byte>
Returns
ToPieces<T>(IEnumerable<T>, int)
[Obsolete("Use MoreLinq Batch method")]
public static IEnumerable<IEnumerable<T>> ToPieces<T>(this IEnumerable<T> src, int countInPicese)
Parameters
src
IEnumerable<T>countInPicese
int
Returns
Type Parameters
T
ToSortedDictionary<TKey, TValue>(IEnumerable<TValue>, Func<TValue, TKey>)
public static SortedDictionary<TKey, TValue> ToSortedDictionary<TKey, TValue>(this IEnumerable<TValue> src, Func<TValue, TKey> getKey)
Parameters
src
IEnumerable<TValue>getKey
Func<TValue, TKey>
Returns
- SortedDictionary<TKey, TValue>
Type Parameters
TKey
TValue
ToStream(byte[])
public static Stream ToStream(this byte[] src)
Parameters
src
byte[]
Returns
ToStream(string)
public static MemoryStream ToStream(this string src)
Parameters
src
string
Returns
ToUtf8Bytes(string)
public static byte[] ToUtf8Bytes(this string src)
Parameters
src
string
Returns
- byte[]
TruncateDecimalPlaces(decimal, int, bool)
public static decimal TruncateDecimalPlaces(this decimal value, int places, bool toUpper = false)
Parameters
Returns
TruncateDecimalPlaces(double, int, bool)
public static double TruncateDecimalPlaces(this double value, int places, bool toUpper = false)