Table of Contents

Class Toolkit

Namespace
SearchAThing.Util
Assembly
netcore-util.dll
public static class Toolkit
Inheritance
Toolkit
Inherited Members

Methods

BuildImage(string, string, CancellationToken, bool, bool, string[]?)

build docker image

public static Task BuildImage(string dockerImageName, string dockerSourceDir, CancellationToken ct, bool sudo = false, bool verbose = false, string[]? extra_args = null)

Parameters

dockerImageName string
dockerSourceDir string
ct CancellationToken
sudo bool
verbose bool
extra_args string[]

Returns

Task

CreateNetwork(string, string, CancellationToken, bool, bool)

create docker network

public static Task CreateNetwork(string networkName, string subnet, CancellationToken ct, bool sudo = false, bool verbose = false)

Parameters

networkName string
subnet string
ct CancellationToken
sudo bool
verbose bool

Returns

Task

DynamicMakeDictionary(dynamic)

convert given dynamic object into a dictionary string,object for its properties

public static IDictionary<string, object>? DynamicMakeDictionary(dynamic obj)

Parameters

obj dynamic

Returns

IDictionary<string, object>

ExecBashRedirect(string, CancellationToken, bool, bool)

start a bash process in background redirecting standard output, error; given script can contains pipe and other shell related redirections. a cancellation token can be supplied to cancel underlying process

public static Task<ExecResult> ExecBashRedirect(string script, CancellationToken ct, bool sudo = false, bool verbose = false)

Parameters

script string

bash script to execute

ct CancellationToken

cancellation token

sudo bool

true if sudo required

verbose bool

if true prints command and args used

Returns

Task<ExecResult>

ExecContainerCmd(string, string, CancellationToken, bool, bool)

executes given bash command into container

public static Task<int> ExecContainerCmd(string containerName, string command, CancellationToken ct, bool sudo = false, bool verbose = false)

Parameters

containerName string
command string
ct CancellationToken
sudo bool
verbose bool

Returns

Task<int>

GetImageNfo(string)

retrieve image nfo

public static MagickImageInfo GetImageNfo(string pathfilename)

Parameters

pathfilename string

Returns

MagickImageInfo

GetImageNfoFromStream(Stream)

retrieve image nfo

public static MagickImageInfo GetImageNfoFromStream(Stream stream)

Parameters

stream Stream

Returns

MagickImageInfo

GetJsonArray(string)

return dynamic array from given [[xx],[yy],...] json array

public static dynamic GetJsonArray(this string jsonDumps)

Parameters

jsonDumps string

Returns

dynamic

ImageSizeMM(MagickImageInfo, double)

retrieve image size width (mm) x height (mm); if no density info present in image defaultDpi argument will used

public static (double widthMM, double heightMM) ImageSizeMM(this MagickImageInfo nfo, double defaultDpi = 96)

Parameters

nfo MagickImageInfo

input magick image nfo

defaultDpi double

used if image density info missing

Returns

(double widthMM, double heightMM)

IsFilePermissionSafe(string, int)

check if given file has required mode ( default = 700 ) to specify mode from octal eg. Convert.ToInt32("700", 8)

public static bool IsFilePermissionSafe(string pathfilename, int mode = 448)

Parameters

pathfilename string
mode int

Returns

bool

ListContainers(CancellationToken, bool, bool)

retrieve list of containers

public static Task<IReadOnlyList<DockerContainerNfo>> ListContainers(CancellationToken ct, bool sudo = false, bool verbose = false)

Parameters

ct CancellationToken
sudo bool
verbose bool

Returns

Task<IReadOnlyList<DockerContainerNfo>>

ListNetworks(CancellationToken, bool, bool)

retrieve list of docker networks

public static Task<IReadOnlyList<DockerNetworkNfo>> ListNetworks(CancellationToken ct, bool sudo = false, bool verbose = false)

Parameters

ct CancellationToken
sudo bool
verbose bool

Returns

Task<IReadOnlyList<DockerNetworkNfo>>

MakeDynamic(params (string name, object value)[])

create a dynamic object containing given set of properties

public static dynamic MakeDynamic(params (string name, object value)[] items)

Parameters

items (string name, object value)[]

Returns

dynamic

RemoveContainer(string, CancellationToken, bool, bool)

remove (stopped) container

public static Task RemoveContainer(string containerName, CancellationToken ct, bool sudo = false, bool verbose = false)

Parameters

containerName string
ct CancellationToken
sudo bool
verbose bool

Returns

Task

RemoveNetwork(string, CancellationToken, bool, bool)

remove docker network

public static Task RemoveNetwork(string networkName, CancellationToken ct, bool sudo = false, bool verbose = false)

Parameters

networkName string
ct CancellationToken
sudo bool
verbose bool

Returns

Task

RunContainer(string, string, string, string, string, string, CancellationToken, bool, bool)

create new container from given image

public static Task RunContainer(string containerName, string containerNetwork, string containerIp, string containerImage, string cpus, string memory, CancellationToken ct, bool sudo = false, bool verbose = false)

Parameters

containerName string
containerNetwork string
containerIp string
containerImage string
cpus string
memory string
ct CancellationToken
sudo bool
verbose bool

Returns

Task

SetFilePermission(string, int)

set file permission of given pathfilename ( eg. Convert.ToInt32("700", 8) )

public static int SetFilePermission(string pathfilename, int mode)

Parameters

pathfilename string
mode int

Returns

int

StopContainer(string, CancellationToken, bool, bool)

stop container

public static Task StopContainer(string containerName, CancellationToken ct, bool sudo = false, bool verbose = false)

Parameters

containerName string
ct CancellationToken
sudo bool
verbose bool

Returns

Task

ToExpando(object)

create an expando object by copying given src

public static ExpandoObject? ToExpando(object src)

Parameters

src object

Returns

ExpandoObject

ToJson(object)

public static string ToJson(object o)

Parameters

o object

Returns

string