ArgumentString 1.0.0
See the version list below for details.
dotnet add package ArgumentString --version 1.0.0
NuGet\Install-Package ArgumentString -Version 1.0.0
<PackageReference Include="ArgumentString" Version="1.0.0" />
paket add ArgumentString --version 1.0.0
#r "nuget: ArgumentString, 1.0.0"
// Install ArgumentString as a Cake Addin #addin nuget:?package=ArgumentString&version=1.0.0 // Install ArgumentString as a Cake Tool #tool nuget:?package=ArgumentString&version=1.0.0
ArgumentString
What is an argument string, you might ask? The idea is borrowed from command line arguments and connection strings.
So an argument string literal looks like this: "foo=bar;version=1"
.
You have some options, e. g. setting mandatory fields that are checked on object instantiation and an easy way to access the arguments by method or by index.
Instantiation
Simplest examples:
var argumentsExample1 = new ArgumentString("foo=bar");
var argumentsExample2 = new ArgumentString("foo=bar;version=1");
Examples with options:
var argumentsExample = new ArgumentString("foo=bar", new ParseOptions("foo"));
var argumentsExample2 = new ArgumentString("foo=bar;version=1",
new ParseOptions("foo") { /* ... */ });
var argumentsExample3 = new ArgumentString("foo=bar;version=1", options => {
options.MandatoryKeys = new List<string> { "foo" };
});
var argumentsExample4 = new ArgumentString("foo->bar|version->1", options => {
options.ArgumentSeparator = "|";
options.KeyValueSeparator = "->";
options.ThrowOnAccessIfKeyNotFound = true;
});
Getting values
Accessing values is the most fun part:
string foo = argumentsExample.Get("foo"); // -> bar
string foo = argumentsExample["foo"]; // -> bar
string foo = argumentsExample.Get(0); // -> bar
string foo = argumentsExample[0]; // -> bar
Dealing with falsy values:
string foo = argumentsExample.Get("missing"); // -> string.Empty if `ThrowOnAccessIfKeyNotFound` is false (default)
string foo = argumentsExample.Get("missing"); // -> MissingArgumentException if `ThrowOnAccessIfKeyNotFound` is true
string foo = argumentsExample["missing"]; // -> same as above
string foo = argumentsExample.Get(2); // -> string.Empty if `ThrowOnAccessIfKeyNotFound` is false (default)
string foo = argumentsExample.Get(2); // -> MissingArgumentException if `ThrowOnAccessIfKeyNotFound` is true
string foo = argumentsExample[2]; // -> same as above
Need to work with a specific format?
You should pay attention to pass correct values for the conversion to work. For that reason there are some more exceptions that will be thrown.
string version = argumentsExample.Get<float>("version"); // -> (float)1
string version = argumentsExample.Get<float>(1); // -> (float)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. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on ArgumentString:
Package | Downloads |
---|---|
Appi.Infrastructure
The goal is to query your sources for information through one tool; all at once, in groups or individually, highly extensible. Use this package to create your own Appi plugins with pre-built infrastructure like SQL Server or MySQL to speed up your development. |
GitHub repositories
This package is not used by any popular GitHub repositories.
initial release