Ministry.Compositions
1.3.0
See the version list below for details.
dotnet add package Ministry.Compositions --version 1.3.0
NuGet\Install-Package Ministry.Compositions -Version 1.3.0
<PackageReference Include="Ministry.Compositions" Version="1.3.0" />
paket add Ministry.Compositions --version 1.3.0
#r "nuget: Ministry.Compositions, 1.3.0"
// Install Ministry.Compositions as a Cake Addin #addin nuget:?package=Ministry.Compositions&version=1.3.0 // Install Ministry.Compositions as a Cake Tool #tool nuget:?package=Ministry.Compositions&version=1.3.0
Introduction
This project provides a suite of extension methods that enable fluent, functional style coding when manipulating objects.
Methods
Collection Compositions
ICollection.AddItem()
Adds the given new object to a collection and returns the collection. To be used as a preferred form to traditional collection Add when chaining is necessary or when updating an EF object tree.
FOR EF: Usage of this method ensures object trees are populated in the correct order for persistence of IDs.
ICollection.AddItems()
Adds the given new collection to a collection and returns the collection. To be used as a preferred form to traditional collection Add when chaining is necessary or when updating an EF object tree.
FOR EF: Usage of this method ensures object trees are populated in the correct order for persistence of IDs.
ICollection.AddItemsIf()
Adds the given new collection, evaluating each item against a given predicate, to a collection and returns the collection. Allows adding collections conditionally, for example, removing duplicates.
object.AddItemsToIf() / object.AddItemsToIfAsync()
Adds the given new collection, evaluating each item against a given predicate, to the specified collection property and returns the parent object. Allows adding collections conditionally, for example, removing duplicates.
object.AddAndReturnItem()
Adds the given new object to a collection and returns the object that was added. To be used as a preferred form to traditional collection Add when chaining is necessary or when updating an EF object tree.
FOR EF: Usage of this method ensures object trees are populated in the correct order for persistence of IDs.
ICollection.RemoveItem()
Removes the given new object from a collection and returns the collection. To be used as a preferred form to traditional collection Add when chaining is necessary or when updating an EF object tree.
FOR EF: Usage of this method ensures object trees are populated in the correct order for persistence of IDs.
ICollection.RemoveItemIf()
Evaluates each item in a collection against a given predicate, removes the offending items, then returns the collection. Allows removing items from collections conditionally, for example, removing duplicates.
Object Compositions
object.Compose() / object.ComposeAsync()
Enables functional composition of a method, enabling chaining. Currently methods with up to 3 parameters are supported. Feel free to form an update to add more parameters - these updates would be most welcome.
object.SetProperty() / object.SetPropertyAsync()
Sets the specified navigation property value on an object to enable chaining and to ensure that the object tree is built in the right order, returning the object.
object.SetAndReturnProperty() / object.SetAndReturnPropertyAsync()
Sets the specified navigation property value on an object to enable chaining and to ensure that the object tree is built in the right order, returning the object property value.
Collection Mutations
These are void return methods.
ICollection.AddRange()
Adds the provided collection to the existing collection.
ICollection.ForEach()
A fluent version of the for each loop. Do NOT use with async calls.
ICollection.ForEachAsync()
A fluent version of the for each loop for async calls.
Projections
object.Project(object)
Projects all property values from the input object on the passed in target object, if they are present in both. This is a really simple way of mapping matching data between types. If choosing to persist existing values please note that, due to it's binary nature, boolean values will not persist and must be re-set. Returns the output object.
object.Project(Func)
Uses the provided function to project one type into another type. Returns the output object.
object.Project(Func, Accumulator)
Uses the provided function to project one type into another type and increments an accumulator. Returns the output object.
IList.Partition()
Partitions the specified list into blocks of the provided size.
IEnumerable.Select()
Various additional overloads for Select. Maps the specified predicate to project each instance of one type in the collection into another type using an accumulator to build value increments for the mapping.
IEnumerable.Flatten()
Flattens a collection of collections down to a single collection.
IEnumerable.Sorted
Sorts the specified collection according to the comparison provided.
The Ministry of Technology Open Source Products
Welcome to The Ministry of Technology open source products. All open source Ministry of Technology products are distributed under the MIT License for maximum re-usability. Details on more of our products and services can be found on our website at http://www.minotech.co.uk
Our other open source repositories can be found here...
Newer content prefers Github. Bitbucket is no longer actively used.
Where can I get it?
You can download the package for this project from any of the following package managers...
Contribution guidelines
If you would like to contribute to the project, please contact me.
Who do I talk to?
- Keith Jackson - keith@minotech.co.uk
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 | netcoreapp1.0 was computed. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard1.6 is compatible. netstandard2.0 was computed. netstandard2.1 was computed. |
.NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 was computed. 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 | tizen30 was computed. 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. |
-
.NETFramework 4.5
- Ministry.FluentGuard (>= 1.0.2)
- Ministry.Reflection (>= 4.0.1)
-
.NETStandard 1.6
- Ministry.FluentGuard (>= 1.0.2)
- Ministry.Reflection (>= 4.0.1)
- NETStandard.Library (>= 1.6.1)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on Ministry.Compositions:
Package | Downloads |
---|---|
Umbraco.Pylon
Core classes to aid with more code orientated Umbraco implementations. |
|
UmbracoPylon.Autofac
Core classes to aid with more code orientated Umbraco implementations. |
|
UmbracoPylon
Core classes to aid with more code orientated Umbraco implementations. |
|
Ministry.Csv
CSV Component Package |
GitHub repositories
This package is not used by any popular GitHub repositories.