Pick.Net.Utilities
1.0.0-preview4
See the version list below for details.
dotnet add package Pick.Net.Utilities --version 1.0.0-preview4
NuGet\Install-Package Pick.Net.Utilities -Version 1.0.0-preview4
<PackageReference Include="Pick.Net.Utilities" Version="1.0.0-preview4" />
paket add Pick.Net.Utilities --version 1.0.0-preview4
#r "nuget: Pick.Net.Utilities, 1.0.0-preview4"
// Install Pick.Net.Utilities as a Cake Addin #addin nuget:?package=Pick.Net.Utilities&version=1.0.0-preview4&prerelease // Install Pick.Net.Utilities as a Cake Tool #tool nuget:?package=Pick.Net.Utilities&version=1.0.0-preview4&prerelease
Pick.Net.Utilites
Various helper classes for C#.
Abstract collection classes
Abstract classes is designed to serve as a base class for creating read-only collections. Methods that modify the collection (i.e. Add
, Clear
, and Remove
) will throw a NotSupportedException
.
- AbstractReadOnlyCollection (
ICollection
,ICollection<T>
&IReadOnlyCollection<<T>
) - AbstractReadOnlyList (
IList
,IList<T>
&IReadOnlyList<T>
) - AbstractReadOnlyDictionary (
IDictionary
,IDictionary<TKey, TValue>
&IReadOnlyDictionary<TKey, TValue>
)
public class SingleItemCollection(string item) : AbstractReadOnlyCollection<string>
{
public override int Count => 1;
public override IEnumerator<string> GetEnumerator()
{
yield return item;
}
}
var collection = new SimpleCollection("test");
var array = collection.ToArray();
// [ "test" ]
((ICollection<T>)collection).Add("another item")
// throws a NotSupportedException
Map
A dictionary-like collection with that allows covariance of the value type parameter and returns null instead of throwing a KeyNotFound exception when accessing a key not in the collection. Only supports reference type values.
var map = new Map<string, string>
{
{ "key1", "value1" },
{ "key2", "value2" },
{ "key3", "value3" }
};
var value1 = map["key1"];
// "value1"
var value4 = map["key4"];
// null
IReadOnlyMap<string, object> objectMap = map;
var value2 = objectMap["key2"];
// "value2"
StringDictionary
A string-keyed dictionary that allows char spans to be used to get values
var map = new StringDictionary<object>
{
{ "key1", "value1" },
{ "key2", "value2" },
{ "key3", "value3" }
};
ReadOnlySpan<char> keys = "key1;key2;key3";
var value1 = map[keys[..4]];
// "value1"
var value2 = map[keys[5..^5]];
// "value2"
var value3 = map[keys[^4..]];
// "value3"
DelegateHelper
Generic version of Delegate.CreateDelegate
, Delegate.Combine
and Delegate.Remove
// instead of
var handler = (Predicate<string>)Delegate.CreateDelegate(typeof(Predicate<string>), method);
// use
var handler = DelegateHelper.CreateDelegate<Predicate<string>>(method);
Shortcuts for System.Action
and System.Func
Action<object> handler = DelegateHelper.CreateAction<object>(method);
Func<int, string, bool> handler = DelegateHelper.CreateFunc<int, string, bool>(method);
Get delegate parameter and return types
ImmutableArray<Type> types = DelegateHelper.GetParameterTypes<Action<string, int>>();
// [ typeof(string), typeof(int) ]
Type types = DelegateHelper.GetReturnType<Func<string>>();
// typeof(string)
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. 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 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. |
-
net7.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Pick.Net.Utilities:
Package | Downloads |
---|---|
Pick.Net.Utilities.Maui
Code generator for creating .NET MAUI BindableProperty declarations and various helper classes for developing MAUI applications |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0-preview5 | 112 | 3/5/2024 |
1.0.0-preview4 | 221 | 12/20/2023 |
1.0.0-preview1 | 81 | 12/6/2023 |