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
dockerImageNamestringdockerSourceDirstringctCancellationTokensudoboolverboseboolextra_argsstring[]
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
networkNamestringsubnetstringctCancellationTokensudoboolverbosebool
Returns
DynamicMakeDictionary(dynamic)
convert given dynamic object into a dictionary string,object for its properties
public static IDictionary<string, object>? DynamicMakeDictionary(dynamic obj)
Parameters
objdynamic
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
scriptstringbash script to execute
ctCancellationTokencancellation token
sudobooltrue if sudo required
verboseboolif 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
containerNamestringcommandstringctCancellationTokensudoboolverbosebool
Returns
GetImageNfo(string)
retrieve image nfo
public static MagickImageInfo GetImageNfo(string pathfilename)
Parameters
pathfilenamestring
Returns
- MagickImageInfo
GetImageNfoFromStream(Stream)
retrieve image nfo
public static MagickImageInfo GetImageNfoFromStream(Stream stream)
Parameters
streamStream
Returns
- MagickImageInfo
GetJsonArray(string)
return dynamic array from given [[xx],[yy],...] json array
public static dynamic GetJsonArray(this string jsonDumps)
Parameters
jsonDumpsstring
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
nfoMagickImageInfoinput magick image nfo
defaultDpidoubleused 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
ctCancellationTokensudoboolverbosebool
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
ctCancellationTokensudoboolverbosebool
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
containerNamestringctCancellationTokensudoboolverbosebool
Returns
RemoveNetwork(string, CancellationToken, bool, bool)
remove docker network
public static Task RemoveNetwork(string networkName, CancellationToken ct, bool sudo = false, bool verbose = false)
Parameters
networkNamestringctCancellationTokensudoboolverbosebool
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
containerNamestringcontainerNetworkstringcontainerIpstringcontainerImagestringcpusstringmemorystringctCancellationTokensudoboolverbosebool
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
containerNamestringctCancellationTokensudoboolverbosebool
Returns
ToExpando(object)
create an expando object by copying given src
public static ExpandoObject? ToExpando(object src)
Parameters
srcobject
Returns
ToJson(object)
public static string ToJson(object o)
Parameters
oobject