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
stringdockerSourceDir
stringct
CancellationTokensudo
boolverbose
boolextra_args
string[]
Returns
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
stringsubnet
stringct
CancellationTokensudo
boolverbose
bool
Returns
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
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
stringbash script to execute
ct
CancellationTokencancellation token
sudo
booltrue if sudo required
verbose
boolif 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
stringcommand
stringct
CancellationTokensudo
boolverbose
bool
Returns
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
MagickImageInfoinput magick image nfo
defaultDpi
doubleused if image density info missing
Returns
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
Returns
ListContainers(CancellationToken, bool, bool)
retrieve list of containers
public static Task<IReadOnlyList<DockerContainerNfo>> ListContainers(CancellationToken ct, bool sudo = false, bool verbose = false)
Parameters
ct
CancellationTokensudo
boolverbose
bool
Returns
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
CancellationTokensudo
boolverbose
bool
Returns
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
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
stringct
CancellationTokensudo
boolverbose
bool
Returns
RemoveNetwork(string, CancellationToken, bool, bool)
remove docker network
public static Task RemoveNetwork(string networkName, CancellationToken ct, bool sudo = false, bool verbose = false)
Parameters
networkName
stringct
CancellationTokensudo
boolverbose
bool
Returns
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
stringcontainerNetwork
stringcontainerIp
stringcontainerImage
stringcpus
stringmemory
stringct
CancellationTokensudo
boolverbose
bool
Returns
SetFilePermission(string, int)
set file permission of given pathfilename ( eg. Convert.ToInt32("700", 8) )
public static int SetFilePermission(string pathfilename, int mode)
Parameters
Returns
StopContainer(string, CancellationToken, bool, bool)
stop container
public static Task StopContainer(string containerName, CancellationToken ct, bool sudo = false, bool verbose = false)
Parameters
containerName
stringct
CancellationTokensudo
boolverbose
bool
Returns
ToExpando(object)
create an expando object by copying given src
public static ExpandoObject? ToExpando(object src)
Parameters
src
object
Returns
ToJson(object)
public static string ToJson(object o)
Parameters
o
object