Logo GenPRES

Informedica.Utils.Lib Namespace

Type/Module Description

App

Holds the data directory of the application domain, or an empty string when the application domain has none.

AppPath

Resolves the application root directory once and returns the root path and the paths of the data, cache, zindex, logs and interactions directories. The root is the directory that holds the data directory, so the development server, a published binary, the Docker container and the test projects all use the same paths. The root is the first of: the directory named by the GENPRES_ROOT environment variable, when that directory exists; the directory of a .env file, searched upward from the current directory and then from the assembly location; the parent of a data/zindex directory, searched upward from the assembly location and then from the current directory; else the current directory, with a warning. The searches for the .env file and the data/zindex directory read the file system directly and do not need Env.loadDotEnv to have run, so test projects and F# scripts find the same root without setup.

Array

Picks, removes, prunes and formats the elements of an array and finds the median and the element nearest to a target.

ConsoleTables

Creates a console table from a sequence of rows and writes the table to the console or to Markdown text.

ConsoleWriter

Writes plain, info, warning, error, debug and question messages to the console in colors. Each message is written under one lock, so messages from concurrent threads do not mix. A debug message is written only when the setting GENPRES_DEBUG is 1.

Csv

Reads a typed value from a named column of a row of text and splits CSV text into rows. An unknown column raises a KeyNotFoundException.

Directory

Walks up the directory tree from a start directory and returns the first directory that meets a condition or holds a given file, or None when no directory does. The module has the same name as the System.IO.Directory class and hides the class in a file that opens both, so the module calls the class by the full name System.IO.Directory.

Env

Reads the environment variables of the process, loads unset variables from a .env file and returns a text with system information.

File

Lists the files of a directory, reads the lines of a file, writes or appends text to a file and tests whether a file exists.

Json

Serializes a value to JSON text and back with Newtonsoft.Json, writing a BigRational as a numerator and a denominator.

List

Finds, replaces, removes and counts the elements of a list and builds the rotations and combinations of lists.

Memoization

Wraps a function in a thread-safe cache, so a repeated call with an equal argument returns the stored result.

NullCheck

Applies a function to one, two or three values and returns a default value when any of the values is null.

Option

Chooses between two option values with a comparison, giving the minimum or the maximum. When only one option holds a value, the result is this option.

Path

Replaces the slashes and backslashes of a path with the directory separator of the platform, combines two paths, and returns the full path of a given path.

Reflection

Converts a union case without fields to its name and a name back to the union case. An unknown name gives None.

Result

Returns the value of an Ok result. Raises an InvalidOperationException for an Error result.

RingBuffer

Creates a mutable buffer of fixed capacity, adds items by overwriting the oldest item when full, and reads the items from oldest to newest.

RingBuffer<'T>

Fixed-size, overwriting ring buffer (oldest -> newest order on iteration)

Seq

Picks, filters, prunes and formats the elements of a sequence and tests whether all elements are equal or unique.

Set

Removes from a set of BigRational values every value which is a multiple of another value in the set, and formats a set as text.

StopWatch

Runs a function, writes the elapsed time in milliseconds with a message to the console and returns the result of the function.

StringBuilder

Wraps the append, format, replace and toString methods of a StringBuilder as functions to use in a pipeline.

Web

Holds the GoogleSheets module, which downloads a Google spreadsheet and reads its sheets.

Xlsx

Reads the sheets of an xlsx workbook as rows of text.

Type something to start searching.