Abstractions
Structr.Abstractions package contains number of classes and extension methods to supply wide range of developer basic needs in different situations.
Big part of package consists of extensions for most popular types allowing to avoid redundant code in widespread cases.
For example You need to add elements to dictionary while overriding values for already existing keys, then you choice is AddRangeOverride dictionary extension. Or some text should be formatted to hyphen-case style. Then ToHyphenCase string extension supplies your needs. Maybe your collection needs some tricky ordering by several fields and directions - advanced OrderBy supplies everything needed. Checking input variables is most common case and many of us are bored by typing another if-null-then-throw statements. Ensure.NotNull (InRange, GreaterThan, etc.) does all this job in one line.
This isn't all. There are extensions for more than ten types, tools for working with async methods, enums, sequential guids, tree-like structures, money types and more. List of all possibilities located below as do some samples.
Installation
Abstractions package is available on NuGet.
Contents
Samples for some of methods
AddRangeOverride
Example of mentioned above AddRangeOverride
dictionary extension:
So after applying extension method will look like:
GetDisplayName
Allows to get Display attribute value for enums:
ToFileSizeString
Converts long
variable to human readable file size in kilobytes, megabytes etc.
Last updated