PowBasics 0.1.6
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package PowBasics --version 0.1.6
NuGet\Install-Package PowBasics -Version 0.1.6
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="PowBasics" Version="0.1.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PowBasics --version 0.1.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: PowBasics, 0.1.6"
#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 PowBasics as a Cake Addin #addin nuget:?package=PowBasics&version=0.1.6 // Install PowBasics as a Cake Tool #tool nuget:?package=PowBasics&version=0.1.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
PowBasics
IEquatable / GetHashCodeAggregate
sealed class ArrRec : IEquatable<ArrRec>
{
public string[] Arr { get; }
public ArrRec(string[] arr) => Arr = arr;
public bool Equals(ArrRec? other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return Arr.Length == other.Arr.Length && Arr.Zip(other.Arr).All(t => t.Item1 == t.Item2);
}
public override bool Equals(object? obj) => ReferenceEquals(this, obj) || obj is ArrRec other && Equals(other);
public override int GetHashCode() => Arr.GetHashCodeAggregate();
public static bool operator ==(ArrRec? left, ArrRec? right) => Equals(left, right);
public static bool operator !=(ArrRec? left, ArrRec? right) => !Equals(left, right);
}
Json
Create a converter
static class Converters
{
public static readonly JsonConverter<Color> ColorConverter = JsonConverterMaker.Make<Color, ColorSer>(
e => new(e.A, e.R, e.G, e.B),
e => Color.FromArgb(e.A, e.R, e.G, e.B)
);
private sealed record ColorSer(byte A, byte R, byte G, byte B);
}
Create a converter factory to convert a generic type
class OptionConverterFactory : JsonConverterFactory
{
public override bool CanConvert(Type typeToConvert) =>
typeToConvert.IsGenericType &&
typeToConvert.GetGenericTypeDefinition() == typeof(Option<>);
public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options)
{
var wrappedType = typeToConvert.GetGenericArguments()[0];
var converter = (JsonConverter)Activator.CreateInstance(typeof(OptionConverter<>).MakeGenericType(wrappedType))!;
return converter;
}
private sealed class OptionConverter<T> : JsonConverter<Option<T>>
{
private sealed record Ser(bool HasValue, T V);
private static Ser ToSer(Option<T> opt) => new(opt.IsSome, opt.IfNoneUnsafe(default(T))!);
private static Option<T> FromSer(Ser ser) => ser.HasValue ? ser.V : None;
public override Option<T> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
using var doc = JsonDocument.ParseValue(ref reader);
return FromSer(doc.Deserialize<Ser>(options)!);
}
public override void Write(Utf8JsonWriter writer, Option<T> value, JsonSerializerOptions options) =>
JsonSerializer.Serialize(writer, ToSer(value), options);
}
}
Product | Versions 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.
-
net8.0
- No dependencies.
NuGet packages (6)
Showing the top 5 NuGet packages that depend on PowBasics:
Package | Downloads |
---|---|
PowWinForms
WinForms reactive utilities |
|
LINQPadExtras
LINQPad utility functions |
|
PowTrees
Tree structure with algorithms |
|
PowLINQPad
Reactive control and utilities for LINQPad |
|
ReactiveVars
Collection of general utility functions |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.2.1 | 178 | 6/30/2024 |
0.2.0 | 130 | 6/30/2024 |
0.1.6 | 158 | 2/12/2024 |
0.1.5 | 137 | 1/31/2024 |
0.1.4 | 106 | 1/31/2024 |
0.1.3 | 112 | 1/31/2024 |
0.1.1 | 120 | 1/19/2024 |
0.1.0 | 122 | 1/19/2024 |
0.0.40 | 176 | 9/16/2023 |
0.0.39 | 160 | 9/16/2023 |
0.0.38 | 133 | 9/16/2023 |
0.0.37 | 182 | 9/16/2023 |
0.0.36 | 148 | 9/16/2023 |
0.0.35 | 171 | 9/15/2023 |
0.0.34 | 187 | 8/23/2023 |
0.0.33 | 177 | 8/22/2023 |
0.0.32 | 297 | 8/5/2023 |
0.0.31 | 160 | 7/30/2023 |
0.0.30 | 222 | 7/12/2023 |
0.0.29 | 185 | 7/12/2023 |
0.0.28 | 172 | 7/11/2023 |
0.0.27 | 193 | 7/10/2023 |
0.0.26 | 166 | 7/10/2023 |
0.0.25 | 153 | 7/10/2023 |
0.0.24 | 179 | 7/9/2023 |
0.0.23 | 184 | 7/5/2023 |
0.0.22 | 176 | 7/5/2023 |
0.0.21 | 187 | 7/5/2023 |
0.0.20 | 170 | 7/5/2023 |
0.0.19 | 144 | 7/5/2023 |
0.0.18 | 192 | 7/4/2023 |
0.0.17 | 169 | 7/2/2023 |
0.0.16 | 166 | 6/21/2023 |
0.0.15 | 167 | 6/15/2023 |
0.0.14 | 168 | 6/15/2023 |
0.0.13 | 151 | 6/15/2023 |
0.0.12 | 165 | 6/12/2023 |
0.0.11 | 183 | 6/5/2023 |
0.0.10 | 210 | 5/28/2023 |
0.0.9 | 206 | 5/28/2023 |
0.0.6 | 378 | 11/26/2022 |
0.0.5 | 344 | 11/26/2022 |
0.0.4 | 510 | 11/15/2022 |