TsadriuUtilities 1.13.1
dotnet add package TsadriuUtilities --version 1.13.1
NuGet\Install-Package TsadriuUtilities -Version 1.13.1
<PackageReference Include="TsadriuUtilities" Version="1.13.1" />
<PackageVersion Include="TsadriuUtilities" Version="1.13.1" />
<PackageReference Include="TsadriuUtilities" />
paket add TsadriuUtilities --version 1.13.1
#r "nuget: TsadriuUtilities, 1.13.1"
#:package TsadriuUtilities@1.13.1
#addin nuget:?package=TsadriuUtilities&version=1.13.1
#tool nuget:?package=TsadriuUtilities&version=1.13.1
TsadriuUtilities
A package with utilities that are useful for web scraping, to make it easier and save a little bit of time.
TsadriuUtilities is a library that helps on dealing with
- Arrays, Chars, Directories, Files, Lists, Numbers, Strings, Generic types and more. I hope this package will make your coding easier and save you a bit of time.
> Features <
ArrayHelper:
- ToString<T>(T[], string separator):
- Converts an
Arrayinto a single line of string. If theseparatoris 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
arraywith random numbers betweenmin(default: 0, inclusive) andmax(default: 100, inclusive).
- Fills up the
- GetValueLike(string[] stringArray, string value, StringComparison stringComparison)
- Iterates through the
stringArray, returning the first item found that containsvalue.
- Iterates through the
- GetValueContaining(string[] stringArray, StringComparison stringComparison, string[] values)
- Iterates through the
stringArray, returning the first item found that contains all thevalues.
- Iterates through the
- AddToElements(string[] stringArray, string startItemTag, string endItemTag)
- Iterates through the
stringArray, addingstartItemTagbefore the item andendItemTagafter the item. Example:startItemTagis 'www.' and the items inside thestringArrayare 'google.com'. This method will return the elements as 'www.google.com'.
- Iterates through the
- RemoveFromElements(string[] stringArray, params string[] valuesToRemove)
- Returns an array where all occasions of
valuesToRemovehave been removed from the elements of thestringArray.
- Returns an array where all occasions of
- ReplaceFromElements(string[] stringArray, string oldValue, string newValue)
- Returns an array where all occasions of
oldValuehave been replaced bynewValuefrom the elements of thestringArray.
- Returns an array where all occasions of
- GetBetween(string[] stringArray, string start, string end, bool startEndIncluded):
- Iterates through the
stringArray, returning the first instance where bothstartandendare found. If none of the indexes matchstartandend, astring.Emptyis returned. UsestartEndIncludedif you want to includestartandendin the returning string.
- Iterates through the
- GetMultipleBetween(string[] stringArray, string start, string end, bool startEndIncluded):
- Searches through the
stringArray, returning multiple instances found betweenstartandend. UsestartEndIncludedif you want to includestartandendin the returning array.
- Searches through the
- KeepBetween(string[] stringArray, string start, string end, bool startEndIncluded, bool excludeEmptyIndexes):
- Iterates through the
stringArray, keeping the content betweenstartandend. IfstartEndIncludedis enabled, the indexes will keep thestartandend. IfexcludeEmptyIndexesis enabled, empty indexes will be removed from the array.
- Iterates through the
- Exclude(string[] stringArray, string[] excludeStrings):
- Iterates through the
stringArray, excluding the indexes that containexcludeStrings.
- Iterates through the
- AddRange<T>(T[] currentArray, T[] arrayToAdd):
- Adds the
currentArrayintoarrayToAdd.
- Adds the
BoolHelper:
- ToBool(string value, SearchType searchType, string[] trueValue, string[] falseValue):
- Tries to parse the
valueinto abool. If the conversion was successfull, it will returnvalueastrueorfalsedepending on where it was found (trueValues,falseValues). Ifvalueis not found in any of those, it'll launch anArgumentOutOfRangeException.
- Tries to parse the
CharHelper:
- ToChar(string value, int index):
- Converts the
valueinto a char. If the length of value is higher than 1, it will return the first character of value or, ifindexis passed, the character of the desiredindex.
- Converts the
DictionaryHelper:
- ToDictionary<TKey, TValue>(List<string> list, string separator, bool invertKeyWithValue):
- Iterates through each element of the
listand splits it byseparator, assigningTKeyto everything that is before theseparatorandTValueto everything that is after theseparator.
- Iterates through each element of the
- FlipKeyWithValue<TKey, TValue>(Dictionary<TKey, TValue> dictionary):
- Returns the
dictionarywhere theTValueis the key andTKeyis the value.
- Returns the
DirectoryHelper:
- Exist(string path, bool createFolder):
- Checks if a
pathexists. IfcreateFolderis true, it will create thepathif it doesn't exist.
- Checks if a
- NotExist(string path, bool createFolder):
- Checks if a
pathdoes not exist. IfcreateFolderis true, it will create thepathif it doesn't exist.
- Checks if a
FileHelper:
- GetFileExtention(string fileName):
- Returns the extention of a
fileName. If thefileNamemultiple extentions (Example: filename.txt.zip), it will return the last extention.
- Returns the extention of a
- Exist(string fullFileName, bool createFile):
- Checks if
fullFileNameexists. IfcreateFileis true, it will create thefullFileNameif it doesn't exist (Keep in mind that the path of thefullFileNamemust exist forcreateFileto work).
- Checks if
- NotExist(string fullFileName, bool createFile):
- Checks if
fullFileNamedoes not exist. IfcreateFileis true, it will create thefullFileNameif it doesn't exist (Keep in mind that the path of thefullFileNamemust exist forcreateFileto work).
- Checks if
HtmlHelper:
- EncodeHtml(string decodedHtml):
- Converts a
decodedHtmlinto a HTML-encoded string.
- Converts a
- DecodeHtml(string encodedHtml):
- Converts a
encodedHtmlinto a decoded string.
- Converts a
- GetHrefLink(string html):
- Checks the
htmland tries to return the first link that is in between the href="".
- Checks the
- GetMultipleHrefLinks(string html):
- Checks the
htmland tries to return multiple links that are in between the href="".
- Checks the
- GetTable(string html):
- Checks the
htmland tries to return the first table that is in between the <table><\table>.
- Checks the
- GetMultipleTables(string html):
- Checks the
htmland tries to return multiple tables that are in between the <table><\table>.
- Checks the
- GetRowsFromTable(string htmlTable):
- Checks the
htmlTableand tries to return the rows that are in between the <tr><\tr>.
- Checks the
- GetDataFromRows(string htmlTable):
- Checks the
htmlTableand tries to return the data that are in between the <td><\td>.
- Checks the
- GetMultipleDataFromTables(List<string> htmlTables):
- Checks the
htmlTablesand tries to return all the data that are in multiple rows of multiple tables.
- Checks the
ListHelper:
- AddRange<T>(List<T> list, T[] array, int startIndex, int endIndex):
- Adds the
arrayinto thelist. IfstatIndexis specified, it will add the contents of thearrayonly 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
listToAddinto thelist. Ifindexis specified, it will add the contents of thelistToAddonly fromindex(included) until the end of the list.
- Adds the
- ToList<T>(T[] array):
- Transforms an
arrayinto a List<T>.
- Transforms an
- OrderByAscending(List<T> list):
- Orders a
listin ascending order.
- Orders a
- OrderByDescending<T>(List<T> list):
- Orders a
listin descending order.
- Orders a
- ToString<T>(List<T> list, string separator, int startIndex, int count)
- Converts an
listinto a single line of string. Ifseparatoris 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 item found that containsvalue.
- Iterates through the
- GetValueContaining(List<string> list, StringComparison stringComparison, string[] values)
- Iterates through the
list, returning the first item found that contains all thevalues.
- Iterates through the
- AddToElements(List<string> list, string startItemTag, string endItemTag)
- Iterates through the
list, addingstartItemTagbefore the item andendItemTagafter the item. Example:startItemTagis 'www.' and the items inside thelistare 'google.com'. This method will return the elements as 'www.google.com'.
- Iterates through the
- RemoveFromElements(List<string> list, params string[] valuesToRemove)
- Returns a list where all occasions of
valuesToRemovehave been removed from the elements of thelist.
- Returns a list where all occasions of
- ReplaceFromElements(List<string> list, string oldValue, string newValue)
- Returns a list where all occasions of
oldValuehave been replaced bynewValuefrom the elements of thelist.
- Returns a list where all occasions of
- GetBetween(List<string> stringList, string start, string end, bool startEndIncluded):
- Iterates through the
stringList, returning the first instance where bothstartandendare found. If none of the indexes matchstartandend, astring.Emptyis returned. UsestartEndIncludedif you want to includestartandendin the returning string.
- Iterates through the
- GetMultipleBetween(List<string> stringList, string start, string end, bool startEndIncluded):
- Searches through the
stringList, returning multiple instances found betweenstartandend. UsestartEndIncludedif you want to includestartandendin the returning List<string>.
- Searches through the
- KeepBetween(List<string> stringList, string start, string end, bool startEndIncluded, bool excludeEmptyIndexes):
- Iterates through the
stringList, keeping the content betweenstartandend. IfstartEndIncludedis enabled, the indexes will keep thestartandend. IfexcludeEmptyIndexesis enabled, empty indexes will be removed from the list.
- Iterates through the
- Exclude(List<string> stringList, string[] excludeStrings):
- Iterates through the
stringList, excluding the indexes that containexcludeStrings.
- Iterates through the
- GetMultipleBetweenIndexes(List<string> stringList, string start, string end, bool startEndIncluded):
- Searches through the
stringList, returningmultiple instances found betweenstartandendfor each index. If you want only one instance per index, please use the methodGetMultipleBetween().
- Searches through the
- SplitListIntoSubLists<T>(List<T> currentList, int elementsPerSubList):
- Splits a generic list into multiple sublists based on the number of elements you want to split, represented by
elementsPerSubList.
- Splits a generic list into multiple sublists based on the number of elements you want to split, represented by
MultiHelper:
- ClampValue<T>(T currentValue, T minValue, T maxValue):
- Clamps
currentValuebased on its' parameters. ReturnsmaxValueifcurrentValueis higher than it and returnsminValueif it is lower than it.
- Clamps
- AreNotNull<T>(params T[] objects):
- Checks if all
objectsare not null. If all ofobjectsare not null, returnstrue. Otherwise returnsfalse.
- Checks if all
- IsBetween<T>(T value, T minValue, T maxValue, bool inclusive):
- Checks if the
valueis in the range ofminValueandmaxValue. Settinginclusiveto true will also includeminValueandmaxValuein the verification.
- Checks if the
- IsEquivalentTo(Type type, Type[] validTypes):
- Determines whether
typeis equivalent to anyvalidTypes.
- Determines whether
NumberHelper:
- ToDecimal(string value):
- Converts
valueinto a decimal. If the conversion fails, returns a0.0M.
- Converts
- ToDouble(string value):
- Converts
valueinto a double. If the conversion fails, returns a0.0d.
- Converts
- ToInt(string value):
- Converts
valueinto 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
- IsNullOrZero<T>(T value):
- Checks if
valueis a null or 0.
- Checks if
StringHelper:
- GetBetween(string text, string start, string end, bool startEndIncluded):
- Searches through the
text, returning the first instance found betweenstartandend. UsestartEndIncludedif you want to includestartandendin the returning string.
- Searches through the
- GetMultipleBetween(string text, string startTag, string endTag, bool tagsIncluded):
- Searches through the
text, returning multiple instances found betweenstartandend. UsestartEndIncludedif you want to includestartandendin the returning List of string.
- Searches through the
- GetBetweenReverse(string text, string start, string end, bool startEndIncluded):
- Searches through the
text, using thestartas the end tag and then searches thetextbackwards until theendtag is found.
- Searches through the
- AndContains(string text, StringComparison stringComparison, string[] values):
- Checks a
stringif 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
stringif 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
valueisnull,string.Emptyor a white space ("", " ", "\n", "\r", ...)
- Checks if the
- IsNotEmpty(string value):
- Check if the
valuecontains any kind of character.
- Check if the
- AreEmpty(string[] values):
- Checks if all instances of
valuesare null, string.Empty or a white space ("", " ", "\n", "\r", ...), returningtrueif all of them are empty.
- Checks if all instances of
- AreNotEmpty(string[] values):
- Checks if all instances of
valuescontain any kind of character, returningtrueif all of them are not empty.
- Checks if all instances of
- LetterUpperCase(string value, int index):
- Changes a letter from
valueto be upper-case. Ifindexis not passed, it will change the first letter ofvalue.
- Changes a letter from
- LetterLowerCase(string value, int index):
- Changes a letter from
valueto be lower-case. Ifindexis 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
valuesToRemovehave been removed from thevalue.
- Returns a string where all instances of
- CharCount(string value, string valueToCount)
- Returns the count of
valueToCountpresent in thevalue.
- Returns the count of
- RemoveTags(string value, string[] tags)
- Returns a string where all instances of
tagsare removed fromvalue(Example: Passing 'b' will remove all '<b>', '</b>' and <b/> xml tags).
- Returns a string where all instances of
- Reverse(string value)
- Reverses a string.
- Split(string value, string separator, bool keepSplitValue)
- Splits the
valuebased on theseparator. UsekeepSplitValueto keep theseparatoron the values.
- Splits the
- SeparateByUpperCase(string value, string separator)
- Separates the
valueby upper-case characters.
- Separates the
- SeparateByLowerCase(string value, string separator)
- Separates the
valueby lower-case characters.
- Separates the
- GetUpperCaseLetters(string value, string separator)
- Reads the
value, returning the present upper-case letters.
- Reads the
- GetLowerCaseLetters(string value, string separator)
- Reads the
value, returning the present lower-case letters.
- Reads the
- SplitBy(string value, SplitType splitType, bool keepSeparator, string separator)
- Splits the
valuebased on thesplitType.
- Splits the
TTable:
- AddColumn(params string[] columnName):
- AddColumn(params TTable[] columnName):
- Adds a new
TTableColumnin theTTable.
- Adds a new
- RenameColumn(string currentColumnName, string newColumnname):
- Renames a column (if it exists).
- GetColumn(params TTable[] columnName):
- Returns an instance of
TTableColumnif it is present inTTable.ColumnList. If it is not present, returns a null.
- Returns an instance of
- GetColumns(int index):
- Returns all
TTableColumnpresent inTTable.ColumnList, or, ifindexis passed, returns theTTableColumnof 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
tableColumnfromTTable.ColumnList(Method will useTTableColumn.ColumnNameto determine whichTTableColumnto remove fromTTable.ColumnList.
- Removes a
- AddData(string columnName, params object[] values):
- AddData(TTableColumn tableColumn, params object[] values):
- Adds
valuesinto theTTableColumnasobject.
- Adds
- ExistsData(string columnName, object value):
- ExistsData(TTableColumn tableColumn, object value):
- Checks through the
TTableColumnforvalue. Returnstrueifvalueis found, otherwisefalse.
- Checks through the
- GetData(string columnName):
- If the
columnNameexists, 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
TTableinto a parseable.csvfile.
- Transform the
- CsvToTable(string fullFileName, string separator):
- Transform a
.csvfile 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
ColumnDataasobject.
- Adds the values in the
- ExistData(object value):
- Checks through the
ColumnDataforvalue. Returnstrueifvalueis found, otherwisefalse.
- Checks through the
- RemoveData(params object[] values):
- Removes all instances of
values.
- Removes all instances of
XmlHelper:
- RemoveEmptyTags(string xml):
- Searches through the
xml, removing empty tags that have the format of <EmptyTag\>.
- Searches through the
| 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 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net5.0
- No dependencies.
-
net6.0
- No dependencies.
-
net7.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 | 650 | 6/14/2023 |
| 1.13.0 | 286 | 6/12/2023 |
| 1.12.6 | 444 | 3/27/2023 |
| 1.12.5 | 341 | 3/27/2023 |
| 1.12.4 | 466 | 3/14/2023 |
| 1.12.3 | 1,143 | 2/9/2023 |
| 1.12.2 | 393 | 2/9/2023 |
| 1.12.1 | 429 | 1/27/2023 |
| 1.12.0 | 1,260 | 1/20/2023 |
| 1.11.0 | 489 | 1/12/2023 |
| 1.10.0 | 1,823 | 10/13/2022 |
| 1.9.0 | 629 | 9/28/2022 |
| 1.8.1 | 634 | 9/12/2022 |
| 1.8.0 | 582 | 9/12/2022 |
| 1.7.0 | 562 | 9/9/2022 |
| 1.6.0 | 683 | 8/29/2022 |
| 1.5.2 | 1,054 | 6/30/2022 |
| 1.5.1 | 589 | 6/28/2022 |
| 1.4.0 | 594 | 6/22/2022 |
| 1.3.2 | 630 | 6/15/2022 |
DateTimeHelper:
- Re-introduced old DateTime helper class. Now it is under the TsadriuUtilitiesOld namespace. This will no longer be maintained, so consider using the TsadriuUtilities.DateTime library as this class will be removed soon from this library.
StringHelper:
- Now it is under the TsadriuUtilitiesOld namespace. This will no longer be maintained, so consider using the TsadriuUtilities.String library as this class will be removed soon from this library.