FluentCoding.String
1.2.1
See the version list below for details.
dotnet add package FluentCoding.String --version 1.2.1
NuGet\Install-Package FluentCoding.String -Version 1.2.1
<PackageReference Include="FluentCoding.String" Version="1.2.1" />
<PackageVersion Include="FluentCoding.String" Version="1.2.1" />
<PackageReference Include="FluentCoding.String" />
paket add FluentCoding.String --version 1.2.1
#r "nuget: FluentCoding.String, 1.2.1"
#:package FluentCoding.String@1.2.1
#addin nuget:?package=FluentCoding.String&version=1.2.1
#tool nuget:?package=FluentCoding.String&version=1.2.1
FluentCoding.String
Add a set of functionalities to manipulate strings
PrependWhen
Allow to prepend ad item into a IEnumerable<string> when the predicate is satisfied
var IEnumerable<string> BuildCsvHeader() { /* do something [...]*/ return csvHeader; }
var IEnumerable<string> BuildCsvContent() { /* do something [...]*/ return csvContent; }
var IEnumerable<string> BuildCsv(bool includeHeader)
{
BuildCsvContent()
.PrependWhen(BuildCsvHeader(), includeHeader)
}
var IEnumerable<string> BuildCsv(bool includeHeader, int currentFileNumber)
{
BuildCsvContent()
.PrependWhen(BuildCsvHeader(), () => currentFileNumber > 1)
}
Concatenate
Add a small set of tools to concatanate string with a bit of logic. For all the following methods the concatenation is enabled only when the base value is not null or default
ConcatLeftToAll, ConcatRightToAll
Take an IEnumerable<string> ad append to each item the input string
internal static string ToCsv(this XElement node, string csvChar) => { /* do something [...]*/ return csvNode;}
internal static string MainNodeToCsv(this XElement rootElement, string csvChar) =>
rootElement.DescendantsAndSelf("Main").First().ToCsv(csvChar)
static IEnumerable<string> BuildCsv(XElement rootElement, string csvChar, bool includeHeader, string externalReference) =>
string.Join(csvChar, externalReference, rootElement.MainNodeToCsv(csvChar))
.ConcatLeftToAll(rootElement.ContentNodesToCsv(csvChar), csvChar)
.PrependWhen(GetCsvHeader(csvChar), () => includeHeader);
List<string> coordinates = new List<string> ("33.21338, 2.71403", "", "7.40338, 22.10301")
var coordinateDescriptions = coordinates.ConcatLeftToAll("Decimal degrees (DD)", " -> ");
/* result:
coordinateDescriptions:
{
"Decimal degrees (DD) -> 33.21338, 2.71403",
"",
"Decimal degrees (DD) -> 7.40338, 22.10301"
}
*/
ConcatRightToWhenWithValue, ConcatLeftToWhenWithValue
Join an input string with the specified value, when the input is not null or default
//Create the address only when the base info 'street-name' is available
public string GetFullAddress(XPathNavigator addressXmlSource) =>
addressXmlSource.GetAttribute("street-name")
.ConcatLeftToWhenWithValue(addressXmlSource.GetAttribute("street-number"))
.ConcatLeftToWhenWithValue(addressXmlSource.GetAttribute("province"));
ConcatWhenWithValue
Join an input string with a left and right string when the input has value
//Create the province description only when the provice is available:
//Example:
//output can be: "Bologna (BO)" or "Bologna"
//but not "Bologna ()" or "()"
public string GetFullAddress(XPathNavigator addressXmlSource) =>
addressXmlSource.GetAttribute("province-name")
.ConcatLeftToWhenWithValue(
addressXmlSource.GetAttribute("province-name-short")
.ConcatWhenWithValue("(", ")")
);
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. 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. 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. |
| .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 is compatible. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 is compatible. 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. |
-
.NETFramework 4.8
- FluentCoding (>= 1.2.1)
-
.NETStandard 2.0
- FluentCoding (>= 1.2.1)
-
.NETStandard 2.1
- FluentCoding (>= 1.2.1)
-
net6.0
- FluentCoding (>= 1.2.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Reworked null management with StringIsNullWhenEnum
Null check applied only on the subject, the append values are used as provided