FluentExtensions.NET 1.4.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package FluentExtensions.NET --version 1.4.0                
NuGet\Install-Package FluentExtensions.NET -Version 1.4.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.4.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FluentExtensions.NET --version 1.4.0                
#r "nuget: FluentExtensions.NET, 1.4.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. 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.4.0

// Install FluentExtensions.NET as a Cake Tool
#tool nuget:?package=FluentExtensions.NET&version=1.4.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 100 .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 for simple actions, FluentExtensions akso increases readability.

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
// Converts boolean value to either "yes" or "No".
string ToYesNo(this bool source);

// Executes an action while the given boolean value is equal to target value.
void DoOn(this bool source, bool result, Action execute);



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);

// Converts given number to kilobytes.
double ToKB(this int number, DigitalStorage from = DigitalStorage.KB);

// Converts given number to megabytes.
double ToMB(this int number, DigitalStorage from = DigitalStorage.MB);

// Converts the given number to gigabytes.
double ToGB(this int number, DigitalStorage from = DigitalStorage.GB);

// Converts the given number to terabytes.
double ToTB(this int number, DigitalStorage from = DigitalStorage.TB)

// Converts given number to kilobytes.
double ToKB(this long number, DigitalStorage from = DigitalStorage.KB);

// Converts given number to megabytes.
double ToMB(this long number, DigitalStorage from = DigitalStorage.MB);

// Converts the given number to gigabytes.
double ToGB(this long number, DigitalStorage from = DigitalStorage.GB);

// Converts the given number to terabytes.
double ToTB(this long number, DigitalStorage from = DigitalStorage.TB)


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.
bool 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.
void 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);

// Adds text to end of another text.
string AddToEnd(this string text, string textToAdd, bool addSpaceBeforeAddition = true);

// Adds text to start of another text.
string AddToStart(this string text, string textToAdd, bool addSpaceAfterAddition = true);

// Gets portion of string based on given characters and position to get.
string Take(this string source, int characters, Position from = Position.Start);

// Replaces multiple values inside a string with one value.
string ReplaceMultipleWithOne(this string source, string[] values, string value);

// Gets the free space of the given drive in gigabytes.
string DriveFreeSpace(this string driveLetter);

// Gets the total size of the given drive in gigabytes.
string DriveTotalSize(this string driveLetter);

// Gets the total size of the given drive in gigabytes.
string DriveTotalSize(this string driveLetter);

// Gets the format of the given drive.
string DriveFormat(this string driveLetter);

// Gets the type of the given drive.
DriveType DriveType(this string driveLetter);

// Delete the given file from disk.
void DeleteFile(this string filePath);

// Hides the given file from disk.
void HideFile(this string filePath);

// Shows the given file from the disk (if it's already hidden).
void ShowFile(this string filePath);

// Gets the date and time when this given file was created.
DateTime CreatedDate(this string filePath);

// Copies the file to the given destination (overwrites it if it already exists).
void CopyFile(this string filePath, string destination);

// Moves the file to the given destination (overwrites it if it already exists).
void MoveFile(this string filePath, string destination);

// Gets the file size in kilobytes.
double FileSizeInKB(this string filePath);

// Gets the file size in megabytes.
double FileSizeInMB(this string filePath);

// Reads the file content as array of bytes.
byte[] ReadBytesFromDisk(this string filePath);

// Reads the file content as array of bytes asynchronously.
Task<byte[]> ReadBytesFromDiskAsync(this string filePath)

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);

// Joins string array into a single string separated via delimiter.
string Join(this IEnumerable<string> texts, string delimiter);

// Converts IEnumerable to list, if it is already a List it returns the list itself.
IList<T> AsList<T>(IEnumerable<T> sourceList);
Product 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 netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
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 495 3/8/2022
1.5.0 407 2/6/2022
1.4.0 420 1/17/2022
1.3.0 361 9/4/2021
1.2.0 300 9/3/2021
1.1.0 294 9/2/2021
1.0.0 343 9/1/2021

v.1.4.0
 New Extensions Added:
 - string Join(this IEnumerable<string> texts, string delimiter);
 - byte[] ReadBytesFromDisk(this string filePath);
 - Task<byte[]> ReadBytesFromDiskAsync(this string filePath);
 - IList<T> AsList<T>(IEnumerable<T> sourceList);
 - string ToYesNo(this bool source);
 - void DoOn(this bool source, bool result, Action execute);

v.1.3.0
 New Extensions Added:
 - string DriveFreeSpace(this string driveLetter);
 - string DriveTotalSize(this string driveLetter);
 - string DriveFormat(this string driveLetter);
 - DriveType DriveType(this string driveLetter);
 - void DeleteFile(this string filePath);
 - void HideFile(this string filePath);
 - void ShowFile(this string filePath);
 - DateTime CreatedDate(this string filePath);
 - void CopyFile(this string filePath, string destination);
 - void MoveFile(this string filePath, string destination);
 - double FileSizeInKB(this string filePath);
 - double FileSizeInMB(this string filePath);

 Fixes:
 - Fix digital storage measurements.
 
v.1.2.0
 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);

v.1.1.0
 - Fix Misspellings.
 - Update icon.

v.1.0.0
 - Initial release.