AnyOf.Newtonsoft.Json
0.5.0.1
Prefix Reserved
dotnet add package AnyOf.Newtonsoft.Json --version 0.5.0.1
NuGet\Install-Package AnyOf.Newtonsoft.Json -Version 0.5.0.1
<PackageReference Include="AnyOf.Newtonsoft.Json" Version="0.5.0.1" />
<PackageVersion Include="AnyOf.Newtonsoft.Json" Version="0.5.0.1" />
<PackageReference Include="AnyOf.Newtonsoft.Json" />
paket add AnyOf.Newtonsoft.Json --version 0.5.0.1
#r "nuget: AnyOf.Newtonsoft.Json, 0.5.0.1"
#addin nuget:?package=AnyOf.Newtonsoft.Json&version=0.5.0.1
#tool nuget:?package=AnyOf.Newtonsoft.Json&version=0.5.0.1
AnyOf
Use the AnyOf<First, TSecond, ...>
type to handle multiple defined types as input parameters for methods.
This project uses code generation to generate up to 10 AnyOf-types:
AnyOf<TFirst, TSecond>
AnyOf<TFirst, TSecond, TThird>
AnyOf<TFirst, TSecond, TThird, TFourth>
- ...
Usage
using System;
using AnyOfTypes;
namespace ConsoleAppConsumer
{
internal class Program
{
private static void Main(string[] args)
{
Console.WriteLine(ReturnSomething().CurrentValue);
X(42);
X("test");
}
// This method returns an string, int or bool in a random way.
private static AnyOf<string, int, bool> ReturnSomething()
{
return new Random().Next(3) switch
{
1 => "test",
2 => 42,
_ => true,
};
}
// This method accepts only an int and a string.
private static void X(AnyOf<int, string> value)
{
Console.WriteLine("ToString " + value.ToString());
Console.WriteLine("CurrentValue " + value.CurrentValue);
Console.WriteLine("IsUndefined " + value.IsUndefined);
Console.WriteLine("IsFirst " + value.IsFirst);
Console.WriteLine("IsSecond " + value.IsSecond);
switch (value.CurrentType)
{
case AnyOfType.First:
Console.WriteLine("AnyOfType = First with value " + value.First);
break;
case AnyOfType.Second:
Console.WriteLine("AnyOfType = Second with value " + value.Second);
break;
default:
Console.WriteLine("???");
break;
}
}
}
}
Sponsors
Entity Framework Extensions and Dapper Plus are major sponsors and proud to contribute to the development of AnyOf, AnyOf.Newtonsoft.Json and AnyOf.System.Text.Json.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 was computed. 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. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp1.0 was computed. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard1.3 is compatible. netstandard1.4 was computed. netstandard1.5 was computed. netstandard1.6 was computed. netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 was computed. 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 | tizen30 was computed. tizen40 was computed. tizen60 was computed. |
Universal Windows Platform | uap was computed. uap10.0 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.5
- Newtonsoft.Json (>= 13.0.3)
- TinyMapper (>= 3.0.3)
-
.NETStandard 1.3
- NETStandard.Library (>= 1.6.1)
- Newtonsoft.Json (>= 13.0.3)
- System.Reflection (>= 4.3.0)
- System.Reflection.Extensions (>= 4.3.0)
- System.Reflection.TypeExtensions (>= 4.3.0)
- TinyMapper (>= 3.0.3)
-
.NETStandard 2.0
- Newtonsoft.Json (>= 13.0.3)
- TinyMapper (>= 3.0.3)
-
.NETStandard 2.1
- Newtonsoft.Json (>= 13.0.3)
- TinyMapper (>= 3.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
# 0.5.0 (24 November 2024)
- #23 Fix AnyOfJsonConverter (string and string list) [bug]
- #22 Null pointer in AnyOfJsonConverter.cs [bug]
The full release notes can be found here: https://github.com/StefH/AnyOf/blob/main/ReleaseNotes.md