Tools.Webkit 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Tools.Webkit --version 1.0.0
NuGet\Install-Package Tools.Webkit -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Tools.Webkit" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Tools.Webkit --version 1.0.0
#r "nuget: Tools.Webkit, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Tools.Webkit as a Cake Addin
#addin nuget:?package=Tools.Webkit&version=1.0.0

// Install Tools.Webkit as a Cake Tool
#tool nuget:?package=Tools.Webkit&version=1.0.0

Webkit

Webkit is a SDK for ASP.NET applications. This SDK provides a wide range of useful tools for data management, logging, authentication, authorization, security, sessions, telemetry and more.

Table of Content

  1. Extensions
  2. Security

Data management

Webkit contains a couple extension methods to make data conversion and management a lot easier.

Webkit.Extensions.Logging

Action<object> DefaultLog(object data)

The method used when Log methods are called. This is defaulted to Console.WriteLine

LoggingExtensions.DefaultLog = (object data) =>
{
	Console.WriteLine(data);
}

<void> <T>.Log(T value)

Performs a .ToString() on value and calls the logging action.

int number = 3;
number.Log(); // 3

<void> <T>.Log(T value, string prependText)

Performs a .ToString() on value, prepends text then calls the logging action.

int number = 3;
number.Log("Number: "); // Number: 3

<void> <T>.Log(T value, string prependText, string appendText)

Performs a .ToString() on value, prepends and appends text then calls the logging action.

int number = 3;
number.Log("There are ", " items left"); // There are 3 items left

<void> <T>.LogAsJson(T value)

Performs a Json.Serialize on value and calls the logging action.

int number = 3;
number.Log(); // 3

<void> <T>.LogAsJson(T value, string prependText)

Performs a Json.Serialize on value, prepends text then calls the logging action.

int number = 3;
number.Log("Number: "); // Number: 3

<void> <T>.LogAsJson(T value, string prependText, string appendText)

Performs a Json.Serialize on value, prepends and appends text then calls the logging action.

int number = 3;
number.Log("There are ", " items left"); // There are 3 items left

<void> <T>.LogAsXml(T value)

Converts value to a XML sheet then calls the logging action.

int number = 3;
number.Log(); // 3

<void> <T>.LogAsXml(T value, string prependText)

Converts value to a XML sheet, prepends text then calls the logging action.

int number = 3;
number.Log("Number: "); // Number: 3

<void> <T>.LogAsXml(T value, string prependText, string appendText)

Converts value to a XML sheet, prepends and appends text then calls the logging action.

int number = 3;
number.Log("There are ", " items left"); // There are 3 items left

Webkit.Extensions.Console

Webkit has a couple extensions to make console logging with color quicker and easier.

<void> ConsoleColor.WriteLine(object value)

Writes value and appends Environment.NewLine to the console with specified console color.

ConsoleColor.Yellow.WriteLine("[Warning] Service is disabled, this may impact user experience."); // [Warning] Service is disabled, this may impact user experience.\r\n

<void> ConsoleColor.Write(object value)

Writes value to the console with specified console color.

ConsoleColor.Yellow.Write("[Warning] Service is disabled, this may impact user experience."); // [Warning] Service is disabled, this may impact user experience.

Webkit.Extensions.DataConversion

These extensions help convert and manage data to different formats.

<string> Stream.AsString()

Converts a stream to a string.

<string> string.Collapse()

Collapses the newlines in the string, making it one line.

@"Lorem ipsum
dolor sit
amet".Collapse();

// Lorem ipsum dolor sit amet

<string> IHeaderDictionary.AsString()

Converts a dictionary of headers to a string.

Request.Headers.AsString();

/*
Host: example.com
Content-Type: text/plain
Content-Length: 57
*/

<string> <T>.AsJson()

Converts any value to a json string

User user = new User()
{
	Name = "John",
	Email = "john@example.com"
};

user.AsJson();

/*
{
	"Name": "John",
	"Email": "john@example.com"
}
*/

<string> <T>.AsXml()

Converts any value to a XML sheet

User user = new User()
{
	Name = "John",
	Email = "john@example.com"
};

user.AsXml();

/*
<User xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<Name>John</Name>
	<Email>john@example.com</Email>
</User>
*/

Webkit.Security

Webkit contains a couple methods to manage data that needs to be cryptographically secure.

<string> CryptographicGenerator.Seed(int length)

Generates a cryptographically safe and universally unique seed. The seed will always be 9 characters longer than specified.

CryptographicGenerator.Seed(40); // Ujg2LLlbu1BspM6kmPk6dT7D71KpmoxbP3uNwJGP-8DC39DE328E6BD3

<string> CryptographicGenerator.UnicodeSeed(int length)

Generates a cryptographically safe and universally unique seed using the unicode range. The seed will always be 9 characters longer than specified.

CryptographicGenerator.UnicodeSeed(40); // ㉔ᩰ⩠ᇤみ᪸ㅇ┗᪄⯿㏹᰷┚₎ḇ◱⡈⚺ᅗ❽⁊ᐬ⫴⏿⺢ሱᴥᙵᙳᓃṵ⯱ᮈ⺶⽢᤹❽㏡⚐㊯-8DC39DE94A69998
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Tools.Webkit:

Package Downloads
Tools.Windows.DockerOrchestrator

An orchestration API designed to be used on Windows platforms with a Docker installation present.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.2 102 3/20/2024
1.0.1 106 3/1/2024
1.0.0 92 3/1/2024