ApacheTech.Common.Extensions
2.0.2
dotnet add package ApacheTech.Common.Extensions --version 2.0.2
NuGet\Install-Package ApacheTech.Common.Extensions -Version 2.0.2
<PackageReference Include="ApacheTech.Common.Extensions" Version="2.0.2" />
paket add ApacheTech.Common.Extensions --version 2.0.2
#r "nuget: ApacheTech.Common.Extensions, 2.0.2"
// Install ApacheTech.Common.Extensions as a Cake Addin #addin nuget:?package=ApacheTech.Common.Extensions&version=2.0.2 // Install ApacheTech.Common.Extensions as a Cake Tool #tool nuget:?package=ApacheTech.Common.Extensions&version=2.0.2
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 | 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 | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. 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.0
- No dependencies.
NuGet packages (4)
Showing the top 4 NuGet packages that depend on ApacheTech.Common.Extensions:
Package | Downloads |
---|---|
ApacheTech.Common.Extensions.Harmony
Extensions methods for reflection, using the AccessTools class, from Harmony. |
|
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.0.2
- Fixed: Allow for nulled actions in `.With(action)`.