FluentExtensions.NET 1.2.0

.NET Standard 2.0
There is a newer version of this package available.
See the version list below for details.
dotnet add package FluentExtensions.NET --version 1.2.0
NuGet\Install-Package FluentExtensions.NET -Version 1.2.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FluentExtensions.NET" Version="1.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FluentExtensions.NET --version 1.2.0
#r "nuget: FluentExtensions.NET, 1.2.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install FluentExtensions.NET as a Cake Addin
#addin nuget:?package=FluentExtensions.NET&version=1.2.0

// Install FluentExtensions.NET as a Cake Tool
#tool nuget:?package=FluentExtensions.NET&version=1.2.0

<p align="center"> <a href="https://github.com/D-Diyare/FluentExtensions"> <img alt="FluentExtensions" width="600" heigth="100" src="https://github.com/D-Diyare/FluentExtensions/blob/master/docs/FluentExtensionsLogo.png"> </a> </p > <br/>

FluentExtensions

Fluent Extensions is a set of more than 70 .NET extensions, it especially made for helping developers to focus on the main tasks rather than get distracted by writing the same code again and again.

Install FluentExtensions via NuGet

If you want to include FluentExtensions in your project, you can install it directly from NuGet

To install FluentExtensions, run the following command in the Package Manager Console

PM> Install-Package FluentExtensions.NET

Documentations

Docs

Extensions

Extensions to Numbers
// Determines whether the given target is even.
bool IsEven(this int source);

// Determines whether the given target is odd.
bool IsOdd(this int source);

// Determines whether the current number is greater than the target one.
bool IsGreaterThan(this int source, int target);

// Determines whether the current number is less than the target one.
bool IsLessThan(this int source, int target);

// Determines whether the current number is equal to the target one.
bool IsEqualTo(this int source, int target);

// Gets the date time in past from given number of days.
DateTime DaysAgo(this int days);

// Gets the date time in future from given number of days.
DateTime DaysAfter(this int days);

// Gets the date time in past from given number of weeks.
DateTime WeeksAgo(this int weeks);

// Gets the date time in future from given number of weeks.
DateTime WeeksAfter(this int weeks);

// Converts the given number into days.
DateTime Days(this int num);

// Gets the date time in future from given number of months.
DateTime MonthsAfter(this int months);

// Gets the date time in past from given number of months.
DateTime MonthsAgo(this int months);

// Gets the date time in past from given number of years.
DateTime YearsAgo(this int years);

// Gets the date time in future from given number of years.
DateTime YearsAfter(this int years);

// Determines whether the given year is a leap year.
bool IsLeapYear(this int year);

// Gets the next leap year based on the given year.
int NextLeapYear(this int year);

// Gets the previous leap year based on the given year.
int PreviousLeapYear(this int year);

// Converts byte array to base64 string.
string FromByeArrayToBase64(this byte[] source, Base64FormattingOptions options = Base64FormattingOptions.None);

// Separates every 3 number by comma.
string SeparateThousandsByComma(this int source);

// Separates every 3 number by comma.
string SeparateThousandsByComma(this int source, CultureInfo culture);

// Generating Random Numbers.
string RandomDigits(this int length);

// Generating Random Numbers.
string GenerateRandomString(this int length, bool isUpperCase = false, bool containNumbers = false);
Extensions to Strings
// Determines whether the given string is Integer.
bool IsInt(this string source);

// Determines whether the given string is Double.
bool IsDouble(this string source);

// Determines whether the given string is Decimal.
bool IsDecimal(this string source);

// Determines whether the given string is Boolean.
IsBoolean(this string source);

// Determines whether the given string is Date.
bool IsDate(this string source);

// Gets string between two strings.
// Credits: https://stackoverflow.com/a/28723216/12352466
string GetInBetween(this string source, string start, string end);

// Converts given text into title case text.
string ToTitleCase(this string source);

// Converts given text into title case text.
string ToTitleCase(this string source, CultureInfo culture);

// Converts string type (True | False) to boolean. 
bool ToBoolean(this string source);

// Determines whether the given string contains digit(s).
bool IsContainDigits(this string source);

// Determines whether the given string contains letter(s).
bool IsContainLetters(this string source);

// Determines whether all characters of the given text are digits.
bool AreAllDigits(this string source);

// Determines whether all characters of the given text are letters.
bool AreAllLetters(this string source);

// Converts back base64 string to byte array;
byte[] FromBase64ToByteArray(this string source);

// Converts string to byte array.
byte[] GetBytes(this string source);

// Converts string to byte array.
byte[] GetBytes(this string source, EncodingType encodingType);

// Determines whether the given text is null or whitespace or empty.
bool IsEmpty(this string source);

// Gets the extension of the file.
string GetFileExtension(this string filePath);

// Determines whether the file exists.
bool FileExists(this string filePath);

// Gets the content of the text file.
ToFileInDisk(this string source, string path);

// Gets the content of the text file asynchronously.
Task ToFileInDiskAsync(this string source, string path);

// Gets the content of the text file.
string ReadFromDisk(this string path);

// Gets the content of the text file asynchronously.
Task<string> ReadFromDiskAsync(this string path);
Extensions to DateTime
// Gets the day after given date.
DateTime Tomorrow(this DateTime current);

// Gets the day before given date.
DateTime Yesterday(this DateTime current);

// Gets an hour after the given date.
DateTime NextHour(this DateTime current);

// Gets an hour before the given date.
DateTime LastHour(this DateTime current);

// Gets a week after the given date.
DateTime NextWeek(this DateTime current);

// Gets a week before the given date.
DateTime LastWeek(this DateTime current);

// Gets a month before the given date.
static DateTime LastMonth(this DateTime current);

// Gets a month after the given date.
DateTime NextMonth(this DateTime current);

// Gets a year before the given date.
DateTime LastYear(this DateTime current);

// Gets a year after the given date.
DateTime NextYear(this DateTime current);

// Gets the number of days prior to the given date.
DateTime DaysAgo(this DateTime source, int days);

// Gets the number of days after the given date.
DateTime DaysAfter(this DateTime source, int days);

// Gets the number of weeks prior the given date.
DateTime WeeksAgo(this DateTime source, int weeks);

// Gets the number of weeks after the given date.
DateTime WeeksAfter(this DateTime source, int weeks);

// Gets the number of months prior the given date.
DateTime MonthsAgo(this DateTime source, int months);

// Gets the number of months after the given date.
DateTime MonthsAfter(this DateTime source, int months);

// Gets the number of years prior the given date.
DateTime YearsAgo(this DateTime source, int years);

// Gets the number of years after the given date.
static DateTime YearsAfter(this DateTime source, int years);

// Gets the first day of month.
DateTime FirstDayOfMonth(this DateTime date);

// Gets the last day of month.
DateTime LastDayOfMonth(this DateTime date);

// Gets the number of days left to the target date.
double DaysLeft(this DateTime source, DateTime target);

// Gets the number of the days of the given date month.
int DaysInMonth(this DateTime date);

// Determines whether the given date is between the two given dates.
bool IsBetween(this DateTime dateToCompare, DateTime startDate, DateTime endDate);

// Determines whether the given date is before the target one.
bool IsBefore(this DateTime dateToCompare, DateTime target);

// Determines whether the given date is already passed the target one.
bool IsAfter(this DateTime dateToCompare, DateTime target);

// Determines whether the given date is a leap year.
bool IsYearLeap(this DateTime date);

// Gets the Next leap year based on the given date.
DateTime NextLeapYear(this DateTime date);

// Gets the previous leap year based on the given date.
DateTime PreviousLeapYear(this DateTime date);

// Calculates age based on given date.
int GetAge(this DateTime date);

// Gets the name of the given date time.
string DayName(this DateTime current);
Extensions to Lists
// Changes a list from mutable (Changeable) to immutable(Not changeable).
IEnumerable<T> ToImmutableList<T>(this IEnumerable<T> sourceList);

// Replaces a list items with another ones items.
static IEnumerable<T> ReplaceWith<T>(this IList<T> sourceList, IEnumerable<T> targetList);

// Picks one item through the list randomly.
T PickRandomItem<T>(this IList<T> sourceList);
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.6.0 182 3/8/2022
1.5.0 168 2/6/2022
1.4.0 183 1/17/2022
1.3.0 246 9/4/2021
1.2.0 175 9/3/2021
1.1.0 172 9/2/2021
1.0.0 203 9/1/2021

New Extensions Added:
- string AddToEnd(this string text, string textToAdd, bool addSpaceBeforeAddition = true);
- string AddToStart(this string text, string textToAdd, bool addSpaceafterAddition = true);
- string ReplaceMultipleWithOne(this string source, string[] values, string value)
- string Take(this string source, int characters, Position from = Position.Start);
- double ToKB(this int number, DigitalStorage from = DigitalStorage.KB);
- double ToMB(this int number, DigitalStorage from = DigitalStorage.MB);
- double ToGB(this int number, DigitalStorage from = DigitalStorage.GB);
- double ToTB(this int number, DigitalStorage from = DigitalStorage.TB);