|
1 |
| -# Simple |
| 1 | +# Simple Extensions |
| 2 | +This library provides simple and very direct extensions on some basic types of C#, although it |
| 3 | +is simple it covers some functionality we need it all the time in many places which sometimes |
| 4 | +casue code duplication due to its simplicity. |
| 5 | + |
| 6 | +My intension is to collect as much as I can of these simple functions and group them in |
| 7 | +single basic libray to help me and others in doing their tasks in an easy way. |
| 8 | + |
| 9 | +This library is open source and covered with unit tests to ensure its stability and to be |
| 10 | +confident to use it in your projects. |
| 11 | + |
| 12 | +In this first release I covered some functions on different C# types and alot is coming |
| 13 | +soon as well. |
| 14 | + |
| 15 | +## What covered now: |
| 16 | +### String Extensions: |
| 17 | +| Method | Description | |
| 18 | +| -- | -- | |
| 19 | +| IsEmpty() | Return `true` if the value is empty only otherwise return `false` | |
| 20 | +| IsNull() | Return `true` if the value is null only otherwise return `false` | |
| 21 | +| IsWhiteSpace() | Return `true` if the value is whitespace only otherwise return `false` | |
| 22 | +| HasValue() | Return `true` if the string has any value, it is simply a wrapper around `IsNullOrWhiteSpace` without the headache of negation | |
| 23 | +| RemoveSpecialCharacters() | Remove any special characters in the string | |
| 24 | +| RemoveSpaces() | Remove any spaces in the string | |
| 25 | +| RemoveSpecialCharactersAndSpaces() | Remove any special characters or spaces in the string | |
| 26 | + |
| 27 | +### DateTime Extensions: |
| 28 | +| Method | Description | |
| 29 | +| -- | -- | |
| 30 | +| ToUnixTimeStamp() | Convert any `DateTime` to unix timestamp | |
| 31 | + |
| 32 | +### Long Extensions: |
| 33 | +| Method | Description | |
| 34 | +| -- | -- | |
| 35 | +| FromUnixTimeStampToDateTime() | Convert unix timestamp to valid `DateTime` | |
| 36 | + |
| 37 | +### Queryable Extensions: |
| 38 | +| Method | Description | |
| 39 | +| -- | -- | |
| 40 | +| ToPaginatedListAsync\<T> | A very simple method for pagination, it is generic which can work on your main entity or projection type. It takes page number and page size and handle the pagination calculations and returns two objects, the first one is the `IEnumerable<T>` with the specified number of records and meta data object with pagination data | |
| 41 | + |
| 42 | +### Enum Extensions: |
| 43 | +| Method | Description | |
| 44 | +| -- | -- | |
| 45 | +| GetAttribute\<TAttribute> | Direct way to retrieve any attribute data associated with `enum` type whether it is built in attribute as `DescriptionAttribute` or any custom attribute | |
| 46 | + |
| 47 | +You can refer to the unit tests in the repo to see some basic usage for each method. |
0 commit comments