Kwargs.Net
1.1.0
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 Kwargs.Net --version 1.1.0
NuGet\Install-Package Kwargs.Net -Version 1.1.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="Kwargs.Net" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Kwargs.Net" Version="1.1.0" />
<PackageReference Include="Kwargs.Net" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Kwargs.Net --version 1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Kwargs.Net, 1.1.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.
#:package Kwargs.Net@1.1.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Kwargs.Net&version=1.1.0
#tool nuget:?package=Kwargs.Net&version=1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Kwargs.Net
This library allows dotnet developers to use **kwargs (Keyword Arguments) to create instance or call function like python developers
Example
CreateInstance
using CreateInstance;
using Kwargs.Net;
Dictionary<string, object> kwargs = new()
{
{ "v1", 5 },
{ "s1", "123" },
};
TestClass testClass = Reflection.CreateInstance<TestClass>(Array.Empty<object>(), kwargs)!;
Console.WriteLine($"V1: {testClass.V1}, S1: {testClass.S1}, V2: {testClass.V2}, S2: {testClass.S2}, F1: {testClass.F1}");
// V1: 5, S1: 123, V2: , S2: , F1:
kwargs = new()
{
{ "v2", 7 },
};
testClass = Reflection.CreateInstance<TestClass>(new object[] { 5, "123" }, kwargs)!;
Console.WriteLine($"V1: {testClass.V1}, S1: {testClass.S1}, V2: {testClass.V2}, S2: {testClass.S2}, F1: {testClass.F1}");
// V1: 5, S1: 123, V2: 7, S2: , F1:
kwargs = new()
{
{ "f1", 5f },
{ "s1", "123" },
};
testClass = Reflection.CreateInstance<TestClass>(new object[] { 5 }, kwargs)!;
Console.WriteLine($"V1: {testClass.V1}, S1: {testClass.S1}, V2: {testClass.V2}, S2: {testClass.S2}, F1: {testClass.F1}");
// V1: 5, S1: 123, V2: , S2: , F1: 5
public class TestClass
{
public int? V1 { get; set; }
public string? S1 { get; set; }
public int? V2 { get; set; }
public string? S2 { get; set; }
public float? F1 { get; set; }
public TestClass(int v1, string s1, int v2 = 5, string? s2 = null)
{
V1 = v1;
S1 = s1;
V2 = v2;
S2 = s2;
}
public TestClass(int v1, string s1)
{
V1 = v1;
S1 = s1;
}
public TestClass(int v1, string s1, int? v2 = null, float? f1 = 17)
{
V1 = v1;
S1 = s1;
V2 = v2;
F1 = f1;
}
}
CallStaticFunction
using CallStaticFunction;
using Kwargs.Net;
var result = Reflection.CallFunction(typeof(TestClass), nameof(TestClass.Test), Array.Empty<object>(), new Dictionary<string, object>());
Console.WriteLine(result);
// 123
public class TestClass
{
public static void Test() { Console.WriteLine("123"); }
public int Test(int a) { Console.WriteLine(a); return a + 1; }
}
CallObjectFunction
using CallObjectFunction;
using Kwargs.Net;
TestClass testClass = new();
var result = Reflection.CallFunction(testClass, nameof(testClass.Test), Array.Empty<object>(), new Dictionary<string, object> { { "a", 5 } });
Console.WriteLine(result);
// 5
// 6
public class TestClass
{
public static void Test() { Console.WriteLine("123"); }
public int Test(int a) { Console.WriteLine(a); return a + 1; }
}
| 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 | 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 was computed. |
| .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.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.