ArgumentString 1.0.2

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

// Install ArgumentString as a Cake Tool
#tool nuget:?package=ArgumentString&version=1.0.2

ArgumentString

.NET 6 Build and Test

What is an argument string, you might ask? The idea is borrowed from connection strings.
So an argument string literal looks like this: "foo=bar;version=1". The library allows you to access these arguments easily by key or by index.

By providing options you can customize this library to your needs, e. g.

  • setting mandatory fields that are checked on object instantiation
  • change argument and key-value separators (like the "foo->bar|version->1" syntax more?)
  • accessing faulty keys will not throw an exception by default, but you can throw one if you like to
  • accessing faulty keys will always return an empty string by default, but you can return null if you like to

This is a tiny but fully tested and stable library.

Installation

  • Install via NuGet: PM> Install-Package ArgumentString
  • Build from your own

Object creation

Simplest examples:

var example = new ArgumentString("foo=bar");
var example = new ArgumentString("foo=bar;version=1");

Examples with options:

var example = new ArgumentString("foo=bar", new ParseOptions("foo"));

var example = new ArgumentString("foo=bar;version=1", 
    new ParseOptions("foo") { /* ... */ });

var example = new ArgumentString("foo=bar;version=1", options => { 
    options.MandatoryKeys = new List<string> { "foo" };
});

var example = new ArgumentString("foo->bar|version->1", options => { 
    options.ArgumentSeparator = "|";
    options.KeyValueSeparator = "->";
    options.ThrowOnAccessIfKeyNotFound = true;
});

Getting values

  • Get(string key) and Get(int index) methods behave the same way
  • See Big O notation (complexity) in the methods description

Accessing values is the most fun part:

string foo = example.Get("foo"); // -> bar
string foo = example["foo"]; // -> bar
string foo = example.Get(0); // -> bar
string foo = example[0]; // -> bar

Dealing with faulty values:

string foo = example.Get("missing"); // -> string.Empty if `ThrowOnAccessIfKeyNotFound` is false (default)
string foo = example.Get("missing"); // -> MissingArgumentException if `ThrowOnAccessIfKeyNotFound` is true
string foo = example["missing"]; // -> same as above

string foo = example.Get(2); // -> string.Empty if `ThrowOnAccessIfKeyNotFound` is false (default)
string foo = example.Get(2); // -> MissingArgumentException if `ThrowOnAccessIfKeyNotFound` is true
string foo = example[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.

float version = example.Get<float>("version"); // -> (float)1 
float version = example.Get<float>(1); // -> (float)1 
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .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.

Version Downloads Last updated
1.0.4 593 8/25/2023
1.0.3 557 8/15/2023
1.0.2 525 8/14/2023
1.0.1 568 8/12/2023
1.0.0 557 8/11/2023

unified namespace