C# Class Applitools.Utils.CommonUtils

Common utilities
Show file Open project: applitools/Eyes.Sdk.DotNet

Public Methods

Method Description
BytesToHexString ( Array array ) : string
ConvertDictionaryKeys ( Dictionary obj ) : TVal>.Dictionary
CopyUpTo ( Stream source, Stream destination, long maxBytes, int bufferSize = 1024 ) : void

Copies up to the specified maximal number of bytes to the destination stream.

DisposeIfNotNull ( IDisposable disposable ) : void

Disposes of the input object unless it is null.

DontThrow ( Action action ) : Exception

Executes the input action and returns an exception if one was thrown.

GetAssemblyTargetFramework_ ( Assembly eyesSeleniumAsm ) : string
GetAttribute ( Enum value ) : TAttribute
GetAttribute ( object value ) : TAttribute
GetDotNetVersion ( ) : string
GetEnvVar ( string envVarName ) : string
GetInnerException ( Exception ex ) : T
GetSha256Hash ( Array bytes ) : string
ReadResourceBytes ( string filename ) : byte[]
ReadResourceFile ( string filename ) : string
ReadResourceFileAsLines ( string filename ) : IList
ReadResourceStream ( string filename ) : Stream
ReadStreamAsLines ( Stream stream ) : IList
ReadToEnd ( Stream stream, int bufferSize = 1024, int length, long maxLength, Logger logger = null ) : byte[]

Returns all the bytes of the input stream.

Retry ( TimeSpan timeout, TimeSpan interval, Func action ) : bool

Runs the input action upon each expiry of interval until action returns true or timeout expires.

SanitizeUrl ( string url ) : string
ToBytesBE ( int value, Stream stream ) : void

Writes the big-endian byte representation of the input value to the target stream.

ToBytesBE ( short value, Stream stream ) : void

Writes the big-endian byte representation of the input value to the target stream.

Private Methods

Method Description
Equals ( ) : System

Method Details

BytesToHexString() public static method

public static BytesToHexString ( Array array ) : string
array Array
return string

ConvertDictionaryKeys() public static method

public static ConvertDictionaryKeys ( Dictionary obj ) : TVal>.Dictionary
obj Dictionary
return TVal>.Dictionary

CopyUpTo() public static method

Copies up to the specified maximal number of bytes to the destination stream.
Thrown if the source stream contains more than /// maxBytes bytes
public static CopyUpTo ( Stream source, Stream destination, long maxBytes, int bufferSize = 1024 ) : void
source Stream Source stream
destination Stream Destination stream
maxBytes long Maximal number of bytes to copy or -1 to allow /// any number of bytes to be copied
bufferSize int Size of chunks read and written
return void

DisposeIfNotNull() public static method

Disposes of the input object unless it is null.
public static DisposeIfNotNull ( IDisposable disposable ) : void
disposable IDisposable
return void

DontThrow() public static method

Executes the input action and returns an exception if one was thrown.
public static DontThrow ( Action action ) : Exception
action Action
return Exception

GetAssemblyTargetFramework_() public static method

public static GetAssemblyTargetFramework_ ( Assembly eyesSeleniumAsm ) : string
eyesSeleniumAsm Assembly
return string

GetAttribute() public static method

public static GetAttribute ( Enum value ) : TAttribute
value Enum
return TAttribute

GetAttribute() public static method

public static GetAttribute ( object value ) : TAttribute
value object
return TAttribute

GetDotNetVersion() public static method

public static GetDotNetVersion ( ) : string
return string

GetEnvVar() public static method

public static GetEnvVar ( string envVarName ) : string
envVarName string
return string

GetInnerException() public static method

public static GetInnerException ( Exception ex ) : T
ex Exception
return T

GetSha256Hash() public static method

public static GetSha256Hash ( Array bytes ) : string
bytes Array
return string

ReadResourceBytes() public static method

public static ReadResourceBytes ( string filename ) : byte[]
filename string
return byte[]

ReadResourceFile() public static method

public static ReadResourceFile ( string filename ) : string
filename string
return string

ReadResourceFileAsLines() public static method

public static ReadResourceFileAsLines ( string filename ) : IList
filename string
return IList

ReadResourceStream() public static method

public static ReadResourceStream ( string filename ) : Stream
filename string
return Stream

ReadStreamAsLines() public static method

public static ReadStreamAsLines ( Stream stream ) : IList
stream Stream
return IList

ReadToEnd() public static method

Returns all the bytes of the input stream.
public static ReadToEnd ( Stream stream, int bufferSize = 1024, int length, long maxLength, Logger logger = null ) : byte[]
stream Stream
bufferSize int
length int
maxLength long
logger Logger
return byte[]

Retry() public static method

Runs the input action upon each expiry of interval until action returns true or timeout expires.
public static Retry ( TimeSpan timeout, TimeSpan interval, Func action ) : bool
timeout TimeSpan
interval TimeSpan
action Func
return bool

SanitizeUrl() public static method

public static SanitizeUrl ( string url ) : string
url string
return string

ToBytesBE() public static method

Writes the big-endian byte representation of the input value to the target stream.
public static ToBytesBE ( int value, Stream stream ) : void
value int
stream Stream
return void

ToBytesBE() public static method

Writes the big-endian byte representation of the input value to the target stream.
public static ToBytesBE ( short value, Stream stream ) : void
value short
stream Stream
return void