Class CommonUtils
- Namespace
 - Sportradar.LiveData.Sdk.Common.Utils
 
- Assembly
 - Sportradar.LiveData.Sdk.dll
 
public static class CommonUtils
  - Inheritance
 - 
      
      CommonUtils
 
- Inherited Members
 
Fields
g_decimal_fmt
public static readonly NumberFormatInfo g_decimal_fmt
  Field Value
Methods
CheckForAnyAttr<T>(T)
public static bool CheckForAnyAttr<T>(T obj)
  Parameters
objT
Returns
Type Parameters
T
ConvertEnumByName<Tout>(string)
public static Tout ConvertEnumByName<Tout>(string orig) where Tout : struct, IConvertible
  Parameters
origstring
Returns
- Tout
 
Type Parameters
Tout
ConvertEnumByName<Tin, Tout>(Tin)
public static Tout ConvertEnumByName<Tin, Tout>(Tin orig) where Tin : struct, IConvertible where Tout : struct, IConvertible
  Parameters
origTin
Returns
- Tout
 
Type Parameters
TinTout
ConvertToResourceName(string)
public static string ConvertToResourceName(string name)
  Parameters
namestring
Returns
Deserialize<T>(byte[])
public static T Deserialize<T>(byte[] arr)
  Parameters
arrbyte[]
Returns
- T
 
Type Parameters
T
EnsureDifferentThread(bool, Action)
When is_different_thread is true run in the same thread, else start a new one
public static void EnsureDifferentThread(bool is_different_thread, Action action)
  Parameters
FromTimespan(TimeSpan)
public static long FromTimespan(TimeSpan ts)
  Parameters
tsTimeSpan
Returns
FromTimestamp(long, DateTimeKind)
Convert from UNIX timestamp to local or UTC timestamp.
public static DateTime FromTimestamp(long time, DateTimeKind convert_to = DateTimeKind.Utc)
  Parameters
timelongUTC time in UNIX format (*1000)
convert_toDateTimeKindDate time kind to convert to
Returns
- DateTime
 Date time of the specified kind
GetEnumMaxValue<TEnum>()
public static TEnum GetEnumMaxValue<TEnum>() where TEnum : IComparable, IConvertible, IFormattable
  Returns
- TEnum
 
Type Parameters
TEnum
GetEnumMinValue<TEnum>()
public static TEnum GetEnumMinValue<TEnum>() where TEnum : IComparable, IConvertible, IFormattable
  Returns
- TEnum
 
Type Parameters
TEnum
GetEnumValue<T>(bool, int, T)
Converts the provided
value to the member of the specified enum, or returns defaultValue
if value of specified is false
public static T GetEnumValue<T>(bool specified, int value, T defaultValue) where T : struct, IConvertible
  Parameters
specifiedboolValue indicating whether the value field was specified in the feed message
valueintThe value in the feed message
defaultValueTA
Tmember to be returned if
is falsespecified
Returns
- T
 The
converted to enumvalueTmember
Type Parameters
TThe type of enum to which to convert the
value
GetEnumValue<T>(int)
Converts the provided
value to the member of the specified enum
public static T GetEnumValue<T>(int value) where T : struct, IConvertible
  Parameters
valueintThe value to be converted
Returns
- T
 The member of the specified enum
Type Parameters
TThe type of enum to which to convert the
value
GetEnumValue<T>(int, T)
Converts the provided
value to the member of the specified enum, or returns defaultValue
public static T GetEnumValue<T>(int value, T defaultValue) where T : struct, IConvertible
  Parameters
valueintThe value in the feed message
defaultValueTA
Tmember to be returned if unknownvalue
Returns
- T
 The
converted to enumvalueTmember
Type Parameters
TThe type of enum to which to convert the
value
GetEnumValue<T>(string)
Converts the provided
value (enum value name) to the member of the specified enum
public static T GetEnumValue<T>(string value) where T : struct, IConvertible
  Parameters
valuestringThe value name to be converted
Returns
- T
 The member of the specified enum
Type Parameters
TThe type of enum to which to convert the
value
GetEnumValue<T>(string, T)
Converts the provided
value (enum value name) to the member of the specified enum
public static T GetEnumValue<T>(string value, T defaultValue) where T : struct, IConvertible
  Parameters
valuestringThe value name to be converted
defaultValueTA
Tmember to be returned if
is not member of enumvalue
Returns
- T
 The member of the specified enum
Type Parameters
TThe type of enum to which to convert the
value
GetTimeSpan(TimeSpan, TimeSpan)
public static TimeSpan GetTimeSpan(TimeSpan ts, TimeSpan default_ts)
  Parameters
Returns
GetVersion(Type)
public static string GetVersion(Type t)
  Parameters
tType
Returns
IntegerToBoolean(int)
IntegerToBoolean
public static bool IntegerToBoolean(int value)
  Parameters
valueint
Returns
IsEnumMember<TEnum>(object)
Determines whether the provided value is member of the specified enumeration
public static bool IsEnumMember<TEnum>(object value) where TEnum : struct
  Parameters
valueobjectThe value to check.
Returns
- bool
 True if the provided value is member of the specified enumeration. Otherwise false.
Type Parameters
TEnumThe enumeration whose members are to be checked
OpenResourceStream(Assembly, Type, string)
public static Stream OpenResourceStream(Assembly assembly, Type type, string name)
  Parameters
Returns
ParseDecimal(string)
public static decimal ParseDecimal(string s)
  Parameters
sstring
Returns
ReadResourceStream(Assembly, Type, string)
public static byte[] ReadResourceStream(Assembly assembly, Type type, string name)
  Parameters
Returns
- byte[]
 
RemoveConsecutiveDots(string)
public static string RemoveConsecutiveDots(string name)
  Parameters
namestring
Returns
SafeWaitTime(TimeSpan)
public static TimeSpan SafeWaitTime(TimeSpan ts)
  Parameters
tsTimeSpan
Returns
Serialize<T>(T)
public static byte[] Serialize<T>(T obj)
  Parameters
objT
Returns
- byte[]
 
Type Parameters
T
StringToBoolean(string)
StringToBoolean
public static bool StringToBoolean(string value)
  Parameters
valuestring
Returns
StringToDateTime(string, string)
StringToDateTime
public static DateTime StringToDateTime(string value, string zone)
  Parameters
Returns
ToTimestamp(DateTime, bool)
public static long ToTimestamp(DateTime time, bool warn = true)