@@ -26,98 +26,250 @@ PM> Install-Package FluentExtensions.NET
26
26
#### Extensions to Numbers
27
27
28
28
``` c#
29
+ // Determines whether the given target is even.
29
30
bool IsEven (this int source );
31
+
32
+ // Determines whether the given target is odd.
30
33
bool IsOdd (this int source );
34
+
35
+ // Determines whether the current number is greater than the target one.
31
36
bool IsGreaterThan (this int source , int target );
37
+
38
+ // Determines whether the current number is less than the target one.
32
39
bool IsLessThan (this int source , int target );
40
+
41
+ // Determines whether the current number is equal to the target one.
33
42
bool IsEqualTo (this int source , int target );
43
+
44
+ // Gets the date time in past from given number of days.
34
45
DateTime DaysAgo (this int days );
46
+
47
+ // Gets the date time in future from given number of days.
35
48
DateTime DaysAfter (this int days );
49
+
50
+ // Gets the date time in past from given number of weeks.
36
51
DateTime WeeksAgo (this int weeks );
52
+
53
+ // Gets the date time in future from given number of weeks.
37
54
DateTime WeeksAfter (this int weeks );
55
+
56
+ // Converts the given number into days.
38
57
DateTime Days (this int num );
58
+
59
+ // Gets the date time in future from given number of months.
39
60
DateTime MonthsAfter (this int months );
61
+
62
+ // Gets the date time in past from given number of months.
40
63
DateTime MonthsAgo (this int months );
64
+
65
+ // Gets the date time in past from given number of years.
41
66
DateTime YearsAgo (this int years );
67
+
68
+ // Gets the date time in future from given number of years.
42
69
DateTime YearsAfter (this int years );
70
+
71
+ // Determines whether the given year is a leap year.
43
72
bool IsLeapYear (this int year );
73
+
74
+ // Gets the next leap year based on the given year.
44
75
int NextLeapYear (this int year );
76
+
77
+ // Gets the previous leap year based on the given year.
45
78
int PreviousLeapYear (this int year );
79
+
80
+ // Converts byte array to base64 string.
46
81
string FromByeArrayToBase64 (this byte [] source , Base64FormattingOptions options = Base64FormattingOptions .None );
82
+
83
+ // Separates every 3 number by comma.
47
84
string SeparateThousandsByComma (this int source );
85
+
86
+ // Separates every 3 number by comma.
48
87
string SeparateThousandsByComma (this int source , CultureInfo culture );
88
+
89
+ // Generating Random Numbers.
49
90
string RandomDigits (this int length );
91
+
92
+ // Generating Random Numbers.
50
93
string GenerateRandomString (this int length , bool isUpperCase = false , bool containNumbers = false );
51
94
```
52
95
53
96
#### Extensions to Strings
54
97
55
98
``` c#
99
+ // Determines whether the given string is Integer.
56
100
bool IsInt (this string source );
101
+
102
+ // Determines whether the given string is Double.
57
103
bool IsDouble (this string source );
104
+
105
+ // Determines whether the given string is Decimal.
58
106
bool IsDecimal (this string source );
107
+
108
+ // Determines whether the given string is Boolean.
59
109
IsBoolean (this string source );
110
+
111
+ // Determines whether the given string is Date.
60
112
bool IsDate (this string source );
113
+
114
+ // Gets string between two strings.
115
+ // Credits: https://stackoverflow.com/a/28723216/12352466
61
116
string GetInBetween (this string source , string start , string end );
117
+
118
+ // Converts given text into title case text.
62
119
string ToTitleCase (this string source );
120
+
121
+ // Converts given text into title case text.
63
122
string ToTitleCase (this string source , CultureInfo culture );
123
+
124
+ // Converts string type (True | False) to boolean.
64
125
bool ToBoolean (this string source );
126
+
127
+ // Determines whether the given string contains digit(s).
65
128
bool IsContainDigits (this string source );
129
+
130
+ // Determines whether the given string contains letter(s).
66
131
bool IsContainLetters (this string source );
132
+
133
+ // Determines whether all characters of the given text are digits.
67
134
bool AreAllDigits (this string source );
135
+
136
+ // Determines whether all characters of the given text are letters.
68
137
bool AreAllLetters (this string source );
138
+
139
+ // Converts back base64 string to byte array;
69
140
byte [] FromBase64ToByteArray (this string source );
141
+
142
+ // Converts string to byte array.
70
143
byte [] GetBytes (this string source );
144
+
145
+ // Converts string to byte array.
71
146
byte [] GetBytes (this string source , EncodingType encodingType );
147
+
148
+ // Determines whether the given text is null or whitespace or empty.
72
149
bool IsEmpty (this string source );
150
+
151
+ // Gets the extension of the file.
73
152
string GetFileExtension (this string filePath );
153
+
154
+ // Determines whether the file exists.
74
155
bool FileExists (this string filePath );
156
+
157
+ // Gets the content of the text file.
75
158
ToFileInDisk (this string source , string path );
159
+
160
+ // Gets the content of the text file asynchronously.
76
161
Task ToFileInDiskAsync (this string source , string path );
162
+
163
+ // Gets the content of the text file.
77
164
string ReadFromDisk (this string path );
165
+
166
+ // Gets the content of the text file asynchronously.
78
167
Task < string > ReadFromDiskAsync (this string path );
79
168
```
80
169
81
170
#### Extensions to DateTime
82
171
83
172
``` c#
173
+ // Gets the day after given date.
84
174
DateTime Tomorrow (this DateTime current );
175
+
176
+ // Gets the day before given date.
85
177
DateTime Yesterday (this DateTime current );
178
+
179
+ // Gets an hour after the given date.
86
180
DateTime NextHour (this DateTime current );
181
+
182
+ // Gets an hour before the given date.
87
183
DateTime LastHour (this DateTime current );
184
+
185
+ // Gets a week after the given date.
88
186
DateTime NextWeek (this DateTime current );
187
+
188
+ // Gets a week before the given date.
89
189
DateTime LastWeek (this DateTime current );
190
+
191
+ // Gets a month before the given date.
90
192
static DateTime LastMonth (this DateTime current );
193
+
194
+ // Gets a month after the given date.
91
195
DateTime NextMonth (this DateTime current );
196
+
197
+ // Gets a year before the given date.
92
198
DateTime LastYear (this DateTime current );
199
+
200
+ // Gets a year after the given date.
93
201
DateTime NextYear (this DateTime current );
202
+
203
+ // Gets the number of days prior to the given date.
94
204
DateTime DaysAgo (this DateTime source , int days );
205
+
206
+ // Gets the number of days after the given date.
95
207
DateTime DaysAfter (this DateTime source , int days );
208
+
209
+ // Gets the number of weeks prior the given date.
96
210
DateTime WeeksAgo (this DateTime source , int weeks );
211
+
212
+ // Gets the number of weeks after the given date.
97
213
DateTime WeeksAfter (this DateTime source , int weeks );
214
+
215
+ // Gets the number of months prior the given date.
98
216
DateTime MonthsAgo (this DateTime source , int months );
217
+
218
+ // Gets the number of months after the given date.
99
219
DateTime MonthsAfter (this DateTime source , int months );
220
+
221
+ // Gets the number of years prior the given date.
100
222
DateTime YearsAgo (this DateTime source , int years );
223
+
224
+ // Gets the number of years after the given date.
101
225
static DateTime YearsAfter (this DateTime source , int years );
226
+
227
+ // Gets the first day of month.
102
228
DateTime FirstDayOfMonth (this DateTime date );
229
+
230
+ // Gets the last day of month.
103
231
DateTime LastDayOfMonth (this DateTime date );
232
+
233
+ // Gets the number of days left to the target date.
104
234
double DaysLeft (this DateTime source , DateTime target );
235
+
236
+ // Gets the number of the days of the given date month.
105
237
int DaysInMonth (this DateTime date );
106
- bool IsBetween (this DateTime dateToCompare ,
107
- DateTime startDate , DateTime endDate );
238
+
239
+ // Determines whether the given date is between the two given dates.
240
+ bool IsBetween (this DateTime dateToCompare , DateTime startDate , DateTime endDate );
241
+
242
+ // Determines whether the given date is before the target one.
108
243
bool IsBefore (this DateTime dateToCompare , DateTime target );
244
+
245
+ // Determines whether the given date is already passed the target one.
109
246
bool IsAfter (this DateTime dateToCompare , DateTime target );
247
+
248
+ // Determines whether the given date is a leap year.
110
249
bool IsYearLeap (this DateTime date );
250
+
251
+ // Gets the Next leap year based on the given date.
111
252
DateTime NextLeapYear (this DateTime date );
253
+
254
+ // Gets the previous leap year based on the given date.
112
255
DateTime PreviousLeapYear (this DateTime date );
256
+
257
+ // Calculates age based on given date.
113
258
int GetAge (this DateTime date );
259
+
260
+ // Gets the name of the given date time.
114
261
string DayName (this DateTime current );
115
262
```
116
263
117
264
#### Extensions to Lists
118
265
119
266
``` c#
267
+ // Changes a list from mutable (Changeable) to immutable(Not changeable).
120
268
IEnumerable < T > ToImmutableList <T >(this IEnumerable < T > sourceList );
269
+
270
+ // Replaces a list items with another ones items.
121
271
static IEnumerable < T > ReplaceWith <T >(this IList < T > sourceList , IEnumerable < T > targetList );
272
+
273
+ // Picks one item through the list randomly.
122
274
T PickRandomItem <T >(this IList < T > sourceList );
123
275
```
0 commit comments