ApacheTech.Common.Extensions
2.1.0
See the version list below for details.
dotnet add package ApacheTech.Common.Extensions --version 2.1.0
NuGet\Install-Package ApacheTech.Common.Extensions -Version 2.1.0
<PackageReference Include="ApacheTech.Common.Extensions" Version="2.1.0" />
<PackageVersion Include="ApacheTech.Common.Extensions" Version="2.1.0" />
<PackageReference Include="ApacheTech.Common.Extensions" />
paket add ApacheTech.Common.Extensions --version 2.1.0
#r "nuget: ApacheTech.Common.Extensions, 2.1.0"
#:package ApacheTech.Common.Extensions@2.1.0
#addin nuget:?package=ApacheTech.Common.Extensions&version=2.1.0
#tool nuget:?package=ApacheTech.Common.Extensions&version=2.1.0
Common Extension Methods
Extension Methods for many different classes within .NET.
This is an inexaustive list of extension methods included within the package.
Collections
Command | Description |
---|---|
myCollection.FirstOrNull<T>() |
Returns the first element of a sequence, or null if the sequence contains no elements. |
myCollection.FirstOrNull<T>(Func<T, bool> predicate) |
Returns the first element of the sequence that satisfies a condition or null if no such element is found. |
myCollection.AddIfNotPresent<T>(T item) |
Adds an item to the "ICollection", if it not already present in the collection. |
myConcurrentBag.AddIfNotPresent<T>(T item) |
Adds an item to the "ConcurrentBag", if it not already present in the collection. |
Enums
Command | Description |
---|---|
myEnum.GetDescription() |
Gets the description for the enum member, decorated with a "DescriptionAttribute". |
myEnum.Count() |
Gets the number of values within this enumeration. |
Strings
Command | Description |
---|---|
myString.IfNullOrWhitespace(string defaultString) |
Returns a default string, if a specified string is "null", empty, or consists only of white-space characters. |
myString.IfNullOrEmpty(string defaultString) |
Returns a default string, if a specified string is "null", or empty. |
myString.StartsWithAny(IEnumerable<string> values) |
Determines whether the beginning of this string instance matches any of the specified strings. |
myString.StartsWithAny(params string[] values) |
Determines whether the beginning of this string instance matches any of the specified strings. |
myString.ContainsAny(IEnumerable<string> values) |
Determines whether the string instance contains any of the specified strings. |
myString.ContainsAny(params string[] values) |
Determines whether the string instance contains any of the specified strings. |
myString.ToOrdinal(int value) |
Converts a number to its ordinal string representation. |
Objects
Command | Description |
---|---|
myObject.DynamicProperties() |
Gets a dynamic collection of properties associated with an object instance, with a lifetime scoped to the lifetime of the object. |
myObject.To<T>() |
Dynamically casts the object instance to a specified type. |
myObject.With<T>(Action<T> work) |
A close approximation to Visual Basic's "With" keyword, that allows batch setting of Properties, without needing to initialise the object. |
Reflection
Command | Description |
---|---|
myAssembly.InstantiateAllTypes<T>(params object[] constructorArgs) |
Scans an assembly for all instantiable classes of a specified type, and forms an array of instances. |
myAssembly.GetTypesWithAttribute<T>() |
Gets the derived types of a specified Attribute, within the assembly. |
myType.GetDerivedTypesFromAssembly(Assembly assembly) |
Gets the derived types of a specified Attribute, within a given assembly. |
myMember.HasCustomAttribute<T>() |
Determines whether the specified member is decorated with the given custom attribute. |
myProperty.TryGetDefaultValue(out object defaultValue) |
Tries the get default value of a property, via its "PropertyInfo". |
myProperty.TryGetDefaultValue<T>(out T defaultValue) |
Tries the get default value of a property, via its "PropertyInfo". |
Tasks
Command | Description |
---|---|
myTask.OnCompletedSuccessfully<TResult, TNewResult>() |
Executes an action when a task has been completed successfully. |
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. 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. |
-
net8.0
- No dependencies.
NuGet packages (3)
Showing the top 3 NuGet packages that depend on ApacheTech.Common.Extensions:
Package | Downloads |
---|---|
ApacheTech.Common.DependencyInjection
A minimal implmentation of the `Microsoft.Extensions.DependencyInjection` package, including the `ActivatorUtilities` class. |
|
ApacheTech.Common.DependencyInjection.Abstractions
A minimal implmentation of the `Microsoft.Extensions.DependencyInjection` package, including the `ActivatorUtilities` class. |
|
VintageStory.Gantry
Gantry MDK is a Mod Developent Kit, used to create third-party plugins for the game Vintage Story, by Anego Studios. |
GitHub repositories
This package is not used by any popular GitHub repositories.
ApacheTech.Common.Extensions v2.1.0
- Build: Updated to .NET 8.0 SDK.