Universal.Common 8.3.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Universal.Common --version 8.3.2                
NuGet\Install-Package Universal.Common -Version 8.3.2                
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="Universal.Common" Version="8.3.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Universal.Common --version 8.3.2                
#r "nuget: Universal.Common, 8.3.2"                
#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 Universal.Common as a Cake Addin
#addin nuget:?package=Universal.Common&version=8.3.2

// Install Universal.Common as a Cake Tool
#tool nuget:?package=Universal.Common&version=8.3.2                

Universal.Common

Support utilities and extensions meant to extend the default functionality from the base class library.

Classes

BinaryReader

Endianness-aware implementation of System.IO.BinaryReader, allowing to read primitive types from a stream in big-endian or little-endian byte order.

using (var stream = new FileStream("file.bin", FileMode.Open, FileAccess.Read))
{
    // Create a BinaryReader with big-endian byte order
    using (var reader = new BinaryReader(stream, Endian.Big))
    {
        // Read an Int32 in big-endian order
        int value = reader.ReadInt32();
    }
}

BinaryWriter

Endianness-aware implementation of System.IO.BinaryWriter, allowing to write primitive types to a stream in big-endian or little-endian byte order.

using (var stream = new FileStream("file.bin", FileMode.Create, FileAccess.Write))
{
    // Create a BinaryWriter with big-endian byte order
    using (var writer = new BinaryWriter(stream, Endian.Big))
    {
        // Write an Int32 in big-endian order
        writer.Write(1234567890);
    }
}

BitSequence

Utility for as-is bit manipulations.

BitSequence bs1 = new BitSequence("10001010"); // Binary representation in string.
BitSequence bs2 = new BitSequence(new bool[] { true, false, true }); // As booleans.
BitSequence bs3 = bs1 & "11110000"; // Bitwise and, implicit conversion from binary representation string.

BitStream

Utility to perform bit-level operations on System.IO.Stream.

using (BitStream bitStream = new BitStream(stream)) 
{
    uint value = bitStream.ReadUInt32(4); // Reads 4 bits from the stream and interprets it as an unsigned integer, padding if necessary.
}

MediaType

Represents MIME types and provides functionality for working with media types in various contexts.

Constructor
MediaType mediaType = new MediaType("application/json");
MediaType Detection

The MediaType class provides several static methods to create MediaType instances from different sources:

  1. FromExtension
MediaType mediaType = MediaType.FromExtension(".json");
// Returns a MediaType instance for "application/json"

Creates a MediaType instance based on a file extension (with or without the leading dot).

  1. FromByteArray
byte[] fileBytes = File.ReadAllBytes("sample.png");
MediaType mediaType = MediaType.FromByteArray(fileBytes);
// Returns a MediaType instance for "image/png"

Detects the media type based on the file signature in the byte array.

  1. FromStream
using (FileStream stream = File.OpenRead("sample.jpg"))
{
    MediaType mediaType = MediaType.FromStream(stream);
    // Returns a MediaType instance for "image/jpeg"
}

Detects the media type based on the file signature read from the stream.

These methods allow for flexible media type detection from various sources, making it easier to work with files and data streams in different formats.

StreamSegment

Represents a segment of a Stream that is itself a stream. This allows you to work with a specific portion of a stream as if it were a separate stream.

using (var stream = new FileStream("file.bin", FileMode.Open, FileAccess.Read))
{
    // Create a StreamSegment that represents the first 1024 bytes of the stream
    using (var segment = new StreamSegment(stream, 0, 1024))
    {
        // Read the first 1024 bytes of the stream
        byte buffer = new byte;
        segment.Read(buffer, 0, 1024);
    }
}

UriBuilder

Derived from System.UriBuilder, this class provides a fluent API to configure segments and queries.

UriBuilder uriBuilder = new UriBuilder("http://www.myhost.com");
uriBuilder
    .AddSegments("api", "Product", 1)
    .AddQuery("key", "value");
// "https://www.myhost.com/api/Product/1?key=value"

ZigZag

Static class that encodes arrays to matrices and vice-versa.

int[,] matrix = new int[,] { { 0, 1 }, { 2, 3 } };
int[] array = ZigZag.ToArray(matrix); // [0, 1, 2, 3]
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.
  • net6.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages (33)

Showing the top 5 NuGet packages that depend on Universal.Common:

Package Downloads
Universal.Common.Reflection

Class library for performing advanced operations with types, dynamic objects, expressions, and reflection.

Universal.Common.Net.Http

Class library to build clients and work with HTTP web services.

Universal.Common.Serialization

Class library with base objects that provide serializable to and from XML and JSON strings and binary serialization using the native binary formatter.

Universal.Android

Class library for accelerating Xamarin.Android development. Note: If you encounter layout inflation exceptions (could be masked as NotFoundException, or some issue with text_color_secondary.xml etc), make sure you define colorControlNormal and use a style with that attribute defined.

Universal.Common.Mathematics

Class library implementing advanced mathematical algorithms, transforms, and time series manipulations. Implementations favour simplicity and correctness.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.3.3 854 a month ago
8.3.2 110 a month ago
8.3.1 121 a month ago
8.3.0 84 a month ago
8.2.5 1,022 5 months ago
8.2.4.1 849 8 months ago
8.2.4 16,893 9/25/2023
8.2.3 760 6/8/2023
8.2.2 2,544 11/23/2022
8.2.1 397 11/22/2022
8.2.0 10,340 9/14/2022
8.1.2 21,678 10/24/2021
8.1.1 479 10/23/2021
8.1.0 483 10/23/2021
8.0.0 13,345 10/13/2021
7.7.1 7,267 8/24/2021
7.7.0 418 8/24/2021
7.6.2 462 8/19/2021
7.6.1 13,041 6/17/2021
7.6.0 2,170 6/3/2021
7.5.7 2,813 4/30/2021
7.5.6 459 4/29/2021
7.5.5 704 4/13/2021
7.5.4 5,322 3/31/2021
7.5.3 5,862 3/21/2021
7.5.2 1,312 3/15/2021
7.5.1 900 2/16/2021
7.5.0 27,477 2/5/2021
7.4.6 507 2/2/2021
7.4.5.1 2,001 1/15/2021
7.4.5 1,132 1/13/2021
7.4.4 1,681 1/7/2021
7.4.3 2,027 12/16/2020
7.4.2.1 577 12/15/2020
7.4.2 544 12/9/2020
7.4.1 5,477 11/26/2020
7.4.0 539 11/26/2020
7.3.5 2,830 11/23/2020
7.3.4 1,796 11/11/2020
7.3.3 572 11/11/2020
7.3.2 1,359 11/1/2020
7.3.1.1 4,714 10/19/2020
7.3.1 554 10/15/2020
7.3.0 552 10/15/2020
7.2.2 3,514 9/29/2020
7.2.1 688 9/29/2020
7.2.0 559 9/29/2020
7.1.1.1 622 9/28/2020
7.1.1 657 9/25/2020
7.1.0 1,797 9/2/2020
7.0.0 6,243 8/24/2020
6.4.7 637 8/21/2020
6.4.6 631 8/21/2020
6.4.5 20,014 5/21/2020
6.4.4 1,901 5/12/2020
6.4.3 2,092 4/23/2020
6.4.2 586 4/20/2020
6.4.1.2 18,248 3/20/2020
6.4.1.1 644 3/20/2020
6.4.1 633 3/20/2020
6.4.0 5,910 2/25/2020
6.3.5 1,252 2/21/2020
6.3.4 700 2/21/2020
6.3.3 3,701 2/11/2020
6.3.2 698 2/11/2020
6.3.1.1 7,210 1/23/2020
6.3.0 4,248 12/18/2019
6.2.7 2,151 12/17/2019
6.2.6 1,326 12/4/2019
6.2.5 833 12/4/2019
6.2.4 3,463 12/1/2019
6.2.3 10,417 10/25/2019
6.2.2 3,523 10/8/2019
6.2.1 1,080 10/7/2019
6.2.0.1 5,408 9/25/2019
6.2.0 1,800 9/20/2019
6.1.5 3,176 9/16/2019
6.1.4.1 1,705 9/9/2019
6.1.4 2,147 9/3/2019
6.1.3 657 9/2/2019
6.1.2 848 8/28/2019
6.1.1 7,595 7/9/2019
6.1.0.1 29,198 7/5/2019
6.1.0 16,910 5/7/2019
6.0.6 1,840 5/3/2019
6.0.5 1,357 5/2/2019
6.0.4 4,740 4/24/2019
6.0.3 1,017 4/24/2019
6.0.2 7,820 3/22/2019
6.0.1.2 2,396 3/12/2019
6.0.1.1 874 3/12/2019
6.0.1 882 3/11/2019
6.0.0 1,664 3/6/2019
5.3.6 816 3/5/2019
5.3.5 784 3/5/2019
5.3.4 1,868 3/4/2019
5.3.3 1,486 2/28/2019
5.3.2 1,306 2/27/2019
5.3.1.1 908 2/25/2019
5.3.1 797 2/25/2019
5.3.0 757 2/25/2019
5.2.1 3,357 2/16/2019
5.2.0.1 3,855 2/7/2019
5.1.8 832 2/7/2019
5.1.7.1 1,069 1/30/2019
5.1.7 838 1/30/2019
5.1.6.1 852 1/24/2019
5.1.6 819 1/23/2019
5.1.5 824 1/23/2019
5.1.4.2 876 1/18/2019
5.1.3 1,576 1/14/2019
5.1.2 7,655 1/8/2019
5.1.1.1 853 1/8/2019
5.1.1 841 1/6/2019
5.1.0 1,448 1/2/2019
5.0.2 872 12/31/2018
5.0.1.1 858 12/31/2018
5.0.1 846 12/31/2018
5.0.0.1 985 12/14/2018
5.0.0 2,147 12/10/2018
4.2.5 911 11/23/2018
4.2.4 934 11/23/2018
4.2.3.1 899 11/22/2018
4.2.3 883 11/22/2018
4.2.2.2 1,158 11/19/2018
4.2.2.1 8,235 10/2/2018
4.2.2 978 10/1/2018
4.2.1.2 997 10/1/2018
4.2.1.1 973 9/27/2018
4.2.1 906 9/26/2018
4.2.0.5 970 9/26/2018
4.2.0.4 951 9/25/2018
4.2.0.3 976 9/25/2018
4.2.0.2 1,000 9/25/2018
4.2.0.1 955 9/25/2018
4.2.0 1,088 9/24/2018
4.1.0 930 9/21/2018
4.0.0.6 969 9/18/2018
4.0.0.5 1,005 9/18/2018
4.0.0.4 979 9/17/2018
4.0.0.3 3,299 9/7/2018
4.0.0.2 1,250 9/4/2018
4.0.0.1 1,352 9/4/2018
4.0.0 4,147 8/30/2018
3.2.0 2,855 8/28/2018
3.1.0 975 8/28/2018
3.0.6 2,557 8/27/2018
3.0.5 959 8/27/2018
3.0.4 989 8/27/2018
3.0.3 1,001 8/24/2018
3.0.2 1,196 8/24/2018
3.0.1.2 973 8/23/2018
3.0.1.1 1,022 8/21/2018
3.0.1 993 8/21/2018
3.0.0 1,907 8/16/2018
2.2.1 1,066 8/15/2018
2.2.0 1,014 8/14/2018
2.1.0 1,014 8/13/2018
2.0.2 1,059 8/7/2018
2.0.1 1,348 5/10/2018
2.0.0 1,936 4/26/2018
1.5.3.7 3,165 1/27/2018
1.5.3.6 1,234 1/15/2018
1.5.3.5 1,210 1/8/2018
1.5.3.4 1,210 1/3/2018
1.5.3.3 1,230 1/3/2018
1.5.3.2 1,220 12/27/2017
1.5.3.1 1,244 12/25/2017
1.5.3 1,181 12/25/2017
1.5.2 1,201 12/24/2017
1.5.1 1,220 12/23/2017
1.5.0 1,173 12/22/2017
1.4.7 1,036 12/2/2017
1.4.6 2,667 11/28/2017
1.4.5 1,226 11/28/2017
1.4.0 1,297 11/12/2017
1.3.5 3,960 11/8/2017
1.3.4 1,293 11/8/2017
1.3.3 1,355 11/2/2017
1.3.2 1,285 11/2/2017
1.3.1 1,328 9/12/2017
1.3.0 1,239 8/26/2017
1.2.1 1,126 8/23/2017
1.2.0 1,197 8/17/2017
1.1.1 1,121 8/17/2017
1.1.0 1,123 8/17/2017
1.0.0 1,938 8/12/2017

Extensions to support reading/writing of null-terminated strings.