Header menu logo Fittings

SaveReadWriter Type

Reads and Writes with Lock, Optionally only once after a delay in which it might be called several times using Text.Encoding.UTF8 Writes Exceptions to errorLogger because it is tricky to catch exceptions form an async thread

Constructors

Constructor Description

SaveReadWriter(path, errorLogger)

Full Usage: SaveReadWriter(path, errorLogger)

Parameters:
    path : string
    errorLogger : string -> unit

Returns: SaveReadWriter

creates a default Lock object

path : string
errorLogger : string -> unit
Returns: SaveReadWriter

SaveReadWriter(path, lockObj, errorLogger)

Full Usage: SaveReadWriter(path, lockObj, errorLogger)

Parameters:
    path : string
    lockObj : obj
    errorLogger : string -> unit

Returns: SaveReadWriter
path : string
lockObj : obj
errorLogger : string -> unit
Returns: SaveReadWriter

Instance members

Instance member Description

this.CreateFileIfMissing

Full Usage: this.CreateFileIfMissing

Parameters:
    text : string

Returns: CreateFileResult

Creates file with text , only if it does not exist yet. Writes Exceptions to errorLogger. Returns true if file exists or was successfully created

text : string
Returns: CreateFileResult

this.FileDoesNotExists

Full Usage: this.FileDoesNotExists

Returns: bool
Returns: bool

this.FileExists

Full Usage: this.FileExists

Returns: bool

Calls IO.File.Exists(path)

Returns: bool

this.Path

Full Usage: this.Path

Returns: string

The full file path

Returns: string

this.ReadAllLines

Full Usage: this.ReadAllLines

Returns: string[] option

Thread Save reading. Ensures that no writing happens while reading. Writes Exceptions to errorLogger

Returns: string[] option

this.ReadAllText

Full Usage: this.ReadAllText

Returns: string option

Thread Save reading. Ensures that no writing happens while reading. Writes Exceptions to errorLogger

Returns: string option

this.WriteAllLinesAsync

Full Usage: this.WriteAllLinesAsync

Parameters:
    texts : string[]

File will be written async and with a Lock. Ensures that no reading happens while writing. Writes Exceptions to errorLogger

texts : string[]

this.WriteAsync

Full Usage: this.WriteAsync

Parameters:
    text : string

File will be written async and with a Lock. Ensures that no reading happens while writing. Writes Exceptions to errorLogger

text : string

this.WriteIfLast

Full Usage: this.WriteIfLast

Parameters:
    getText : unit -> string
    delayMilliSeconds : int

GetString will be called in sync on calling thread, but file will be written async. Only if after the delay the counter value is the same as before. That means no more recent calls to this function have been made during the delay. If other calls to this function have been made then only the last call will be written as file. Also ensures that no reading happens while writing. Writes Exceptions to errorLogger

getText : unit -> string
delayMilliSeconds : int

Type something to start searching.