Table of Contents

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

NumberFormatInfo

Methods

CheckForAnyAttr<T>(T)

public static bool CheckForAnyAttr<T>(T obj)

Parameters

obj T

Returns

bool

Type Parameters

T

ConvertEnumByName<Tout>(string)

public static Tout ConvertEnumByName<Tout>(string orig) where Tout : struct, IConvertible

Parameters

orig string

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

orig Tin

Returns

Tout

Type Parameters

Tin
Tout

ConvertToResourceName(string)

public static string ConvertToResourceName(string name)

Parameters

name string

Returns

string

Deserialize<T>(byte[])

public static T Deserialize<T>(byte[] arr)

Parameters

arr byte[]

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

is_different_thread bool

boolean condition

action Action

action to be executed

FromTimespan(TimeSpan)

public static long FromTimespan(TimeSpan ts)

Parameters

ts TimeSpan

Returns

long

FromTimestamp(long, DateTimeKind)

Convert from UNIX timestamp to local or UTC timestamp.

public static DateTime FromTimestamp(long time, DateTimeKind convert_to = DateTimeKind.Utc)

Parameters

time long

UTC time in UNIX format (*1000)

convert_to DateTimeKind

Date 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

specified bool

Value indicating whether the value field was specified in the feed message

value int

The value in the feed message

defaultValue T

A T member to be returned if

specified
is false

Returns

T

The

value
converted to enum T member

Type Parameters

T

The 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

value int

The value to be converted

Returns

T

The member of the specified enum

Type Parameters

T

The 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

value int

The value in the feed message

defaultValue T

A T member to be returned if unknown

value

Returns

T

The

value
converted to enum T member

Type Parameters

T

The 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

value string

The value name to be converted

Returns

T

The member of the specified enum

Type Parameters

T

The 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

value string

The value name to be converted

defaultValue T

A T member to be returned if

value
is not member of enum

Returns

T

The member of the specified enum

Type Parameters

T

The type of enum to which to convert the

value

GetTimeSpan(TimeSpan, TimeSpan)

public static TimeSpan GetTimeSpan(TimeSpan ts, TimeSpan default_ts)

Parameters

ts TimeSpan
default_ts TimeSpan

Returns

TimeSpan

GetVersion(Type)

public static string GetVersion(Type t)

Parameters

t Type

Returns

string

IntegerToBoolean(int)

IntegerToBoolean

public static bool IntegerToBoolean(int value)

Parameters

value int

Returns

bool

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

value object

The value to check.

Returns

bool

True if the provided value is member of the specified enumeration. Otherwise false.

Type Parameters

TEnum

The enumeration whose members are to be checked

OpenResourceStream(Assembly, Type, string)

public static Stream OpenResourceStream(Assembly assembly, Type type, string name)

Parameters

assembly Assembly
type Type
name string

Returns

Stream

ParseDecimal(string)

public static decimal ParseDecimal(string s)

Parameters

s string

Returns

decimal

ReadResourceStream(Assembly, Type, string)

public static byte[] ReadResourceStream(Assembly assembly, Type type, string name)

Parameters

assembly Assembly
type Type
name string

Returns

byte[]

RemoveConsecutiveDots(string)

public static string RemoveConsecutiveDots(string name)

Parameters

name string

Returns

string

SafeWaitTime(TimeSpan)

public static TimeSpan SafeWaitTime(TimeSpan ts)

Parameters

ts TimeSpan

Returns

TimeSpan

Serialize<T>(T)

public static byte[] Serialize<T>(T obj)

Parameters

obj T

Returns

byte[]

Type Parameters

T

StringToBoolean(string)

StringToBoolean

public static bool StringToBoolean(string value)

Parameters

value string

Returns

bool

StringToDateTime(string, string)

StringToDateTime

public static DateTime StringToDateTime(string value, string zone)

Parameters

value string
zone string

Returns

DateTime

ToTimestamp(DateTime, bool)

public static long ToTimestamp(DateTime time, bool warn = true)

Parameters

time DateTime
warn bool

Returns

long