CLibNl 0.7.6

A collection of utilities in F#.

Install-Package CLibNl -Version 0.7.6
dotnet add package CLibNl --version 0.7.6
<PackageReference Include="CLibNl" Version="0.7.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CLibNl --version 0.7.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

module Seq

  • groupAndCount (groupingMapper:'a->'b) (data:seq<'a>)
  • groupAndCountElements data

module List

  • groupAndCount (groupingMapper:'a->'b) (data:List<'a>)
  • groupAndCountElements data

module Array

  • groupAndCount (groupingMapper:'a->'b) (data:'a[])
  • groupAndCountElements data

module CSharpInterop

  • TryGetValue(o:Option<'a>, def:'a)
  • HasValue(o:Option<'a>)
  • GetValue(o:Option<'a>)
  • OfFsFunc(f:('a->'b))
  • OfFunc(func:Func<'a, 'b>)

module Patterns

  • module Inventory
    • Nsn

module DateTimeExtensions

  • DateTime.WeekOf()
  • ParseObject

module Option

  • ToNullable()

module Nullable

  • ToOption()

module FileSystemExtensions

  • FileInfo.Open()
  • DirectoryInfo.Open()
  • Uri.Open()
  • FileInfo.Serialize()
  • FileInfo.Deserialize()

module String

  • ToEnum<'T>()
  • ToSentence()
  • DecomposeString()

module Int32

  • ToHex()
  • FromHex()
  • ToBin()
  • FromBin()

module Excel

  • ToExcelObject()
  • ToExcelObjectArray()

module Cache

module Log

  • CLib.Log
  • CLib.AppLogs

module AsyncTaskRunner

module PrintToConsole

module RecordArrayToObjectArray

module PrintToConsoleExec

Draw Table

Overview

The table consists of objects that implement the ICell interface. The main implementation of this interface is TextCell, which has overloaded constructors to support various content types.

ICell Interface

The ICell interface has two get properties and one method.

| Member | Description |
| - | - |
| MinHeight | The minimum number of character lines needed to draw the cell. |
| MinWidth | The minimum number of characters need to draw the longest line in the cell. |
| Draw | The method draws cell contents into a string of height represented by the first parameter, and width represented by the second parameter. |

TextCell

TextCell allows the user to display multiple lines of text in a single cell. The lines are provided through the lines:string[] constructor parameter. The user can also specify text alignment through the textAlignment:TextAlignment constructor parameter.

TextCell Constructors

| Parameters | Description |
| --- | --- |
| string*TextAlignment | Simple string content. |
| string | Simple string content, aligned left. |
| bool | Boolean value mapped into "T" or "F", aligned center. |
| int | Integer value, thousands comma-separated, aligned right. |
| float*FloatingPointStyle | Floating point number with specified formatting, aligned right. |
| float*int | Floating point number rounded to the given number of decimal places, aligned right. |
| float | Floating point number rounded to 4 decimal places, aligned right. |
| DateTime | Only date: dd-MMM-yy aligned center. Only time: HH:mm:ss aligned center. Date and time: date on line 1 and time on line 2, aligned center. |
| Option&lt;&#39;a&gt; | Recognized types for &#39;a behave as described above when the Option is Some. All other Some options are treated as text through the ToString() method. None options are replaced with - as text. |
| obj | The parameter is matched against above types. If it's an unrecognized type, the ToString() method is used to represent the text as string. |

Sequence Mapping

An array of TextCell objects can be iterated over through the AsICell static method. For example:

let data : TextCell[] = ...
let dataI : ICell[] =
    data
    |> Array.map TextCell.AsICell

Table

A text table can be created by:

  1. Constructing the Table object
  2. Calling the Draw() method to create the string (or, alternatively, the Print() method to output directly to the console)

Table Constructors

| Parameters | Description |
| - | - |
| obj[][]*bool | The object array is an array of arrays, where the inner arrays represent row columns, and the outter array represents rows. Individual obj entries are matched against defined types as described above. The Boolean parameter indicates whether or not borders should be draw with the table. |
| &#39;a[]*bool | The first parameter is a single column array that is automattically mapped into the above constructor. |

Utility Methods and Examples

The above objects can be used with defined constructors. The library also comes with auto-opened PrintToConsoleExec module which contains two utility functions.

Utility Methods

| Method | Descriptoin |
| - | - |
| printWithBorders | Utility function that automatically outputs to the console an array of arrays (obj[][]) input (with borders). |
| printRecordsAsTable | Utility function that automatically extracts table columns from record fields and then outputs the results to the console (with borders). |

Examples

Record as Table
type Test =
    {
        C1 : int
        C2 : float 
    }

    static member Sample() = ...

printRecordsAsTable (Test.Sample())
String Array as Table
let data =
    [|
        [| "Header 1"; "Header 2" |]
        [| "Data 1"; "Data 2" |]
    |]

printWithBorders data

module Seq

  • groupAndCount (groupingMapper:'a->'b) (data:seq<'a>)
  • groupAndCountElements data

module List

  • groupAndCount (groupingMapper:'a->'b) (data:List<'a>)
  • groupAndCountElements data

module Array

  • groupAndCount (groupingMapper:'a->'b) (data:'a[])
  • groupAndCountElements data

module CSharpInterop

  • TryGetValue(o:Option<'a>, def:'a)
  • HasValue(o:Option<'a>)
  • GetValue(o:Option<'a>)
  • OfFsFunc(f:('a->'b))
  • OfFunc(func:Func<'a, 'b>)

module Patterns

  • module Inventory
    • Nsn

module DateTimeExtensions

  • DateTime.WeekOf()
  • ParseObject

module Option

  • ToNullable()

module Nullable

  • ToOption()

module FileSystemExtensions

  • FileInfo.Open()
  • DirectoryInfo.Open()
  • Uri.Open()
  • FileInfo.Serialize()
  • FileInfo.Deserialize()

module String

  • ToEnum<'T>()
  • ToSentence()
  • DecomposeString()

module Int32

  • ToHex()
  • FromHex()
  • ToBin()
  • FromBin()

module Excel

  • ToExcelObject()
  • ToExcelObjectArray()

module Cache

module Log

  • CLib.Log
  • CLib.AppLogs

module AsyncTaskRunner

module PrintToConsole

module RecordArrayToObjectArray

module PrintToConsoleExec

Draw Table

Overview

The table consists of objects that implement the ICell interface. The main implementation of this interface is TextCell, which has overloaded constructors to support various content types.

ICell Interface

The ICell interface has two get properties and one method.

| Member | Description |
| - | - |
| MinHeight | The minimum number of character lines needed to draw the cell. |
| MinWidth | The minimum number of characters need to draw the longest line in the cell. |
| Draw | The method draws cell contents into a string of height represented by the first parameter, and width represented by the second parameter. |

TextCell

TextCell allows the user to display multiple lines of text in a single cell. The lines are provided through the lines:string[] constructor parameter. The user can also specify text alignment through the textAlignment:TextAlignment constructor parameter.

TextCell Constructors

| Parameters | Description |
| --- | --- |
| string*TextAlignment | Simple string content. |
| string | Simple string content, aligned left. |
| bool | Boolean value mapped into "T" or "F", aligned center. |
| int | Integer value, thousands comma-separated, aligned right. |
| float*FloatingPointStyle | Floating point number with specified formatting, aligned right. |
| float*int | Floating point number rounded to the given number of decimal places, aligned right. |
| float | Floating point number rounded to 4 decimal places, aligned right. |
| DateTime | Only date: dd-MMM-yy aligned center. Only time: HH:mm:ss aligned center. Date and time: date on line 1 and time on line 2, aligned center. |
| Option&lt;&#39;a&gt; | Recognized types for &#39;a behave as described above when the Option is Some. All other Some options are treated as text through the ToString() method. None options are replaced with - as text. |
| obj | The parameter is matched against above types. If it's an unrecognized type, the ToString() method is used to represent the text as string. |

Sequence Mapping

An array of TextCell objects can be iterated over through the AsICell static method. For example:

let data : TextCell[] = ...
let dataI : ICell[] =
    data
    |> Array.map TextCell.AsICell

Table

A text table can be created by:

  1. Constructing the Table object
  2. Calling the Draw() method to create the string (or, alternatively, the Print() method to output directly to the console)

Table Constructors

| Parameters | Description |
| - | - |
| obj[][]*bool | The object array is an array of arrays, where the inner arrays represent row columns, and the outter array represents rows. Individual obj entries are matched against defined types as described above. The Boolean parameter indicates whether or not borders should be draw with the table. |
| &#39;a[]*bool | The first parameter is a single column array that is automattically mapped into the above constructor. |

Utility Methods and Examples

The above objects can be used with defined constructors. The library also comes with auto-opened PrintToConsoleExec module which contains two utility functions.

Utility Methods

| Method | Descriptoin |
| - | - |
| printWithBorders | Utility function that automatically outputs to the console an array of arrays (obj[][]) input (with borders). |
| printRecordsAsTable | Utility function that automatically extracts table columns from record fields and then outputs the results to the console (with borders). |

Examples

Record as Table
type Test =
    {
        C1 : int
        C2 : float 
    }

    static member Sample() = ...

printRecordsAsTable (Test.Sample())
String Array as Table
let data =
    [|
        [| "Header 1"; "Header 2" |]
        [| "Data 1"; "Data 2" |]
    |]

printWithBorders data

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
0.7.6 460 3/14/2018
0.7.5 408 3/13/2018
0.7.3 411 2/10/2018
0.7.2 426 2/10/2018
0.7.1 429 2/6/2018
0.7.0 380 2/6/2018
0.6.1 401 2/3/2018
0.6.0 445 2/1/2018
0.5.0 411 1/25/2018
0.4.0 406 1/21/2018
0.3.0 395 1/12/2018
0.2.0 398 12/25/2017
0.1.0 384 12/25/2017
0.0.4 424 12/25/2017
0.0.3-beta 398 12/25/2017
0.0.2-beta 379 12/23/2017
0.0.1-beta 393 12/23/2017