ApacheTech.Common.Extensions 2.1.0

There is a newer version of this package available.
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
                    
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="ApacheTech.Common.Extensions" Version="2.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ApacheTech.Common.Extensions" Version="2.1.0" />
                    
Directory.Packages.props
<PackageReference Include="ApacheTech.Common.Extensions" />
                    
Project file
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 ApacheTech.Common.Extensions --version 2.1.0
                    
#r "nuget: ApacheTech.Common.Extensions, 2.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 ApacheTech.Common.Extensions@2.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=ApacheTech.Common.Extensions&version=2.1.0
                    
Install as a Cake Addin
#tool nuget:?package=ApacheTech.Common.Extensions&version=2.1.0
                    
Install as a Cake Tool

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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.

Version Downloads Last Updated
2.1.1 118 9/14/2025
2.1.0 102 9/14/2025
2.0.2 566 9/15/2023
2.0.1 2,749 1/6/2023
2.0.0 616 11/15/2022
1.2.0 9,301 7/23/2022
1.1.1 899 12/17/2021

ApacheTech.Common.Extensions v2.1.0

- Build: Updated to .NET 8.0 SDK.