TsadriuUtilities 1.4.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package TsadriuUtilities --version 1.4.0
NuGet\Install-Package TsadriuUtilities -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="TsadriuUtilities" Version="1.4.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TsadriuUtilities --version 1.4.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: TsadriuUtilities, 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 TsadriuUtilities as a Cake Addin #addin nuget:?package=TsadriuUtilities&version=1.4.0 // Install TsadriuUtilities as a Cake Tool #tool nuget:?package=TsadriuUtilities&version=1.4.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
TsadriuUtilities
A small package with utilities to save a little bit of time in coding.
TsadriuUtilities is a library that helps on dealing with
- Arrays, Chars, Date and Time, Directories, Files, Lists, Numbers, Strings and Generic types, to hopefully make coding easier while also saving a bit of time.
> Features <
ArrayHelper:
- ToString<T>(T[], string separator):
- Converts an
Array
into a single line of string. If theseparator
is not passed, it will separate by a space. Examples: ArrayToString(new int[] { 1, 3, 5 }) → "1 3 5", ArrayToString(new string[] { "5", "2" }, "|") → "5|2".
- Converts an
- GenerateRandom<T>(T[] array, int min, int max):
- Fills up the
array
with random numbers betweenmin
(default: 0, inclusive) andmax
(default: 100, inclusive).
- Fills up the
CharHelper:
- ToChar(string value, int index):
- Converts the
value
into a char. If the length of value is higher than 1, it will return the first character of value or, ifindex
is passed, the character of the desiredindex
.
- Converts the
DateTimeHelper:
- ToDateTime(string dateAsString, string dateFormat, CultureInfo cultureInfo):
- ToDateTime(string dateAsString, string[] dateFormats, CultureInfo cultureInfo):
- Tries to convert a
date
from a string to a type ofDateTime
.
- Tries to convert a
- GetLastDayOfMonth(DateTime date):
- Parses the
date
to return with the last day of the month.
- Parses the
- SetDay(DateTime date, int day):
- Sets the
day
in thedate
. In case theday
is higher than the month's max days, it will be clamped.
- Sets the
- SetMonth(DateTime date, int month):
- Sets the
month
in thedate
. In case themonth
is higher than the year's maximum months, it will be clamped.
- Sets the
- SetYear(DateTime date, int year):
- Sets the
year
in thedate
.
- Sets the
- RemoveDays(DateTime date, int days):
- Removes a specified number of
days
fromdate
.
- Removes a specified number of
- RemoveMonths(DateTime date, int months):
- Removes a specified number of
months
fromdate
.
- Removes a specified number of
- RemoveYears(DateTime date, int years):
- Removes a specified number of
years
fromdate
.
- Removes a specified number of
DictionaryHelper:
- ToDictionary<TKey, TValue>(List<string> list, string separator, bool invertKeyWithValue):
- Iterates through each element of the
list
and splits it byseparator
, assigningTKey
to everything that is before theseparator
andTValue
to everything that is after theseparator
.
- Iterates through each element of the
DirectoryHelper:
- Exist(string path, bool createFolder):
- Checks if a
path
exists. IfcreateFolder
is true, it will create thepath
if it doesn't exist.
- Checks if a
- NotExist(string path, bool createFolder):
- Checks if a
path
does not exist. IfcreateFolder
is true, it will create thepath
if it doesn't exist.
- Checks if a
FileHelper:
- GetFileExtention(string fileName):
- Returns the extention of a
fileName
. If thefileName
multiple extentions (Example: filename.txt.zip), it will return the last extention.
- Returns the extention of a
- Exist(string fullFileName, bool createFile):
- Checks if
fullFileName
exists. IfcreateFile
is true, it will create thefullFileName
if it doesn't exist (Keep in mind that the path of thefullFileName
must exist forcreateFile
to work).
- Checks if
- NotExist(string fullFileName, bool createFile):
- Checks if
fullFileName
does not exist. IfcreateFile
is true, it will create thefullFileName
if it doesn't exist (Keep in mind that the path of thefullFileName
must exist forcreateFile
to work).
- Checks if
ListHelper:
- AddRange<T>(List<T> list, T[] array, int startIndex, int endIndex):
- Adds the
array
into thelist
. IfstatIndex
is specified, it will add the contents of thearray
only fromstartIndex
(included) until the end of the array or until it reachesendIndex
(included) if it is specified.
- Adds the
- AddRange<T>(List<T> list, List<T> listToAdd, int index):
- Adds the
listToAdd
into thelist
. Ifindex
is specified, it will add the contents of thelistToAdd
only fromindex
(included) until the end of the list.
- Adds the
- ToList<T>(T[] array):
- Transforms an
array
into a List<T>.
- Transforms an
- OrderByAscending(List<T> list):
- Orders a
list
in ascending order.
- Orders a
- OrderByDescending<T>(List<T> list):
- Orders a
list
in descending order.
- Orders a
- ToString<T>(List<T> list, string separator, int startIndex, int count)
- Converts an
list
into a single line of string. Ifseparator
is not passed, it will separate by a space. Examples: ListToString(new int[] { 1, 3, 5 }) → "1 3 5", ListToString(new string[] { "5", "2" }, "|") → "5|2".
- Converts an
- HasAny<T>(List<T> list)
- Iterates through the
list
, checking that it has at least 1 non null element.
- Iterates through the
- GetValueLike(List<string> list, string value, StringComparison stringComparison)
- Iterates through the
list
, returning the first value found that containsvalue
.
- Iterates through the
- RemoveFromElements(List<string> list, string value, StringComparison stringComparison)
- Returns a list where all occasions of
valuesToRemove
have been removed from the elements of thelist
.
- Returns a list where all occasions of
- ReplaceFromElements(List<string> list, string value, StringComparison stringComparison)
- Returns a list where all occasions of
oldValue
have been replaced bynewValue
from the elements of thelist
.
- Returns a list where all occasions of
MultiHelper:
- ClampValue<T>(T currentValue, T minValue, T maxValue):
- Clamps
currentValue
based on its' parameters. ReturnsmaxValue
ifcurrentValue
is higher than it and returnsminValue
if it is lower than it.
- Clamps
NumberHelper:
- ToDecimal(string value):
- Converts
value
into a decimal. If the conversion fails, returns a0.0M
.
- Converts
- ToDouble(string value):
- Converts
value
into a double. If the conversion fails, returns a0.0d
.
- Converts
- ToInt(string value):
- Converts
value
into a int. If the conversion fails, returns a0
.
- Converts
- Max<T>(T[] sequence):
- Returns the highest number present in the
sequence
.
- Returns the highest number present in the
- Min<T>(T[] sequence):
- Returns the lowest number present in the
sequence
.
- Returns the lowest number present in the
- Between<T>(T value, T min, T max, bool included):
- Checks if the
value
is betweenmin
andmax
. Settingincluded
to true will also includemin
andmax
in the verification.
- Checks if the
StringHelper:
- GetBetween(string text, string start, string end, bool startEndIncluded):
- Searches through the
text
, returning the first instance found betweenstart
andend
. UsestartEndIncluded
if you want to includestart
andend
in the returning string.
- Searches through the
- GetMultipleBetween(string text, string startTag, string endTag, bool tagsIncluded):
- Searches through the
text
, returning multiple instances found betweenstart
andend
. UsestartEndIncluded
if you want to includestart
andend
in the returning List of string.
- Searches through the
- AndContains(string text, StringComparison stringComparison, string[] values):
- Checks a
string
if it has all instances ofvalues
. If that's the case, then it returnstrue
, otherwise it returnsfalse
.
- Checks a
- OrContains(string text, StringComparison stringComparison, string[] values):
- Checks a
string
if it has at least one instance ofvalues
. If that's the case, then it returnstrue
, otherwise it returnsfalse
.
- Checks a
- IsEmpty(string value):
- Checks if the
value
isnull
,string.Empty
or a white space ("", " ", "\n", "\r", ...)
- Checks if the
- IsNotEmpty(string value):
- Check if the
value
contains any kind of character.
- Check if the
- AreEmpty(string[] values):
- Checks if all instances of
values
are null, string.Empty or a white space ("", " ", "\n", "\r", ...), returningtrue
if all of them are empty.
- Checks if all instances of
- AreNotEmpty(string[] values):
- Checks if all instances of
values
contain any kind of character, returningtrue
if all of them are not empty.
- Checks if all instances of
- LetterUpperCase(string value, int index):
- Changes a letter from
value
to be upper-case. Ifindex
is not passed, it will change the first letter ofvalue
.
- Changes a letter from
- LetterLowerCase(string value, int index):
- Changes a letter from
value
to be lower-case. Ifindex
is not passed, it will change the first letter ofvalue
.
- Changes a letter from
- Remove(string value, params string[] valuesToRemove):
- Returns a string where all instances of
valuesToRemove
have been removed from thevalue
.
- Returns a string where all instances of
- CharCount(string value, string valueToCount)
- Returns the count of
valueToCount
present in thevalue
.
- Returns the count of
- RemoveTags(string value, string tag)
- RemoveTags(string value, string[] tags)
- Returns a string where all instances of
tags
are removed fromvalue
(Example: Passing 'b' will remove all '<b>', '</b>' and <b/> xml tags).
- Returns a string where all instances of
TTable:
- AddColumn(params string[] columnName):
- AddColumn(params TTable[] columnName):
- Adds a new
TTableColumn
in theTTable
.
- Adds a new
- GetColumn(params TTable[] columnName):
- Returns an instance of
TTableColumn
if it is present inTTable.ColumnList
. If it is not present, returns a null.
- Returns an instance of
- GetColumns(int index):
- Returns all
TTableColumn
present inTTable.ColumnList
, or, ifindex
is passed, returns theTTableColumn
of the desiredindex
.
- Returns all
- MoveColumnIndex(TTableColumn tableColumn, int newIndex):
- MoveColumnIndex(string columnName, int newIndex)
- Moves a
tableColumn
's index tonewIndex
.
- Moves a
- RemoveColumn(params TTableColumn[] tableColumn):
- RemoveColumn(params string[] columnName)
- Removes a
tableColumn
fromTTable.ColumnList
(Method will useTTableColumn.ColumnName
to determine whichTTableColumn
to remove fromTTable.ColumnList
.
- Removes a
- AddData(string columnName, params object[] values):
- AddData(TTableColumn tableColumn, params object[] values):
- Adds
values
into theTTableColumn
asobject
.
- Adds
- ExistsData(string columnName, object value):
- ExistsData(TTableColumn tableColumn, object value):
- Checks through the
TTableColumn
forvalue
. Returnstrue
ifvalue
is found, otherwisefalse
.
- Checks through the
- GetData(string columnName):
- If the
columnName
exists, returns all the data present in theTTableColumn
.
- If the
- RemoveData(string columnName, params object[] valuesToRemove):
- RemoveData(TTableColumn tableColumn, params object[] valuesToRemove):
- Removes all instances of
valuesToRemove
.
- Removes all instances of
- TableToCsv(bool addHeader, string separator):
- Transform the
TTable
into a parseable.csv
file.
- Transform the
- CsvToTable(string fullFileName, string separator):
- Transform a
.csv
file into aTTable
.
- Transform a
TTableColumn:
- string ColumnName { get; set; }:
- Gets or sets the name of the column.
- List<object> ColumnData { get; set; }:
- Gets or sets the data in the column.
- AddData(params object[] values):
- Adds the values in the
ColumnData
asobject
.
- Adds the values in the
- ExistData(object value):
- Checks through the
ColumnData
forvalue
. Returnstrue
ifvalue
is found, otherwisefalse
.
- Checks through the
- RemoveData(params object[] values):
- Removes all instances of
values
.
- Removes all instances of
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net5.0
- No dependencies.
-
net6.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.13.1 | 498 | 6/14/2023 | |
1.13.0 | 156 | 6/12/2023 | |
1.12.6 | 324 | 3/27/2023 | |
1.12.5 | 211 | 3/27/2023 | |
1.12.4 | 326 | 3/14/2023 | |
1.12.3 | 915 | 2/9/2023 | |
1.12.2 | 264 | 2/9/2023 | |
1.12.1 | 307 | 1/27/2023 | |
1.12.0 | 1,007 | 1/20/2023 | |
1.11.0 | 352 | 1/12/2023 | |
1.10.0 | 1,588 | 10/13/2022 | |
1.9.0 | 471 | 9/28/2022 | |
1.8.1 | 492 | 9/12/2022 | |
1.8.0 | 430 | 9/12/2022 | |
1.7.0 | 417 | 9/9/2022 | |
1.6.0 | 528 | 8/29/2022 | |
1.5.2 | 891 | 6/30/2022 | |
1.5.1 | 443 | 6/28/2022 | |
1.4.0 | 449 | 6/22/2022 | |
1.3.2 | 463 | 6/15/2022 | |
1.3.1 | 478 | 6/15/2022 | |
1.3.0 | 517 | 6/13/2022 | |
1.2.0 | 468 | 6/2/2022 | |
1.1.1 | 460 | 5/30/2022 | |
1.1.0 | 462 | 5/25/2022 | |
1.0.15 | 449 | 5/13/2022 | |
1.0.14 | 448 | 5/4/2022 | |
1.0.13 | 461 | 5/3/2022 | |
1.0.12 | 454 | 4/28/2022 | |
1.0.11 | 480 | 3/4/2022 | |
1.0.8 | 474 | 2/23/2022 | |
1.0.7 | 467 | 2/23/2022 | |
1.0.6 | 502 | 2/18/2022 | |
1.0.5 | 519 | 2/10/2022 | |
1.0.4 | 526 | 1/31/2022 | |
1.0.3 | 527 | 1/27/2022 | |
1.0.2 | 580 | 11/9/2021 | |
1.0.1 | 563 | 11/9/2021 |
DateTimeHelper:
- Implemented method RemoveDays.
- Implemented method RemoveMonths.
- Implemented method RemoveYears.
DictionaryHelper:
- New helper implemented.
- Implemented method ToDictionary.
ListHelper:
- Implemented method GetValueLike.
- Implemented method RemoveFromElements.
- Implemented method ReplaceFromElements.
StringHelper:
- Bug on method AreNotEmpty that made it not work as intended has been fixed.