Skip to content

Commit

Permalink
added split reverse function
Browse files Browse the repository at this point in the history
  • Loading branch information
gary-holland committed Dec 14, 2020
1 parent ddfba14 commit eedb1a2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
22 changes: 20 additions & 2 deletions src/dexih.functions.builtIn/MapFunctions.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml;
Expand Down Expand Up @@ -96,7 +97,7 @@ public string Replace(string value, string oldValue, string newValue)
}

[TransformFunction(FunctionType = EFunctionType.Map, Category = "String", Name = "Split",
Description = "Splits a string into multiple return fields that are based on the characters in an array.")]
Description = "Splits a string into multiple return fields using the separator as the delimiter")]
public int Split(string value, string separator, int? count, out string[] result)
{
if (string.IsNullOrEmpty(value) || string.IsNullOrEmpty(separator))
Expand All @@ -110,6 +111,22 @@ public int Split(string value, string separator, int? count, out string[] result
return result.Length;
}

[TransformFunction(FunctionType = EFunctionType.Map, Category = "String", Name = "Split Reverse",
Description = "Splits a string into multiple return fields (in reverse) using the separator as the delimiter")]
public int SplitReverse(string value, string separator, out string[] result)
{
if (string.IsNullOrEmpty(value) || string.IsNullOrEmpty(separator))
{
result = null;
return 0;
}

result = value.Split(separator.ToCharArray()).Reverse().ToArray();

return result.Length;
}


[TransformFunction(FunctionType = EFunctionType.Map, Category = "String", Name = "Substring",
Description =
"Retrieves a substring from this instance. The substring starts at a specified character position and has a specified length.")]
Expand Down Expand Up @@ -478,7 +495,8 @@ public T Switch<T>(object value, [TransformFunctionLinkedParameter("When")] obje

return defaultValue;
}



}

}
Expand Down
7 changes: 6 additions & 1 deletion src/dexih.transforms/Table/TableColumn.cs
Expand Up @@ -383,7 +383,12 @@ public void ResetFormat(bool force = false)
case ETypeCode.UInt16:
case ETypeCode.UInt32:
case ETypeCode.UInt64:
Format = "#,##0";
// if the column is a tracking or non-tracking field, it is likely to be a value which should be formatted with commas.
if (DeltaType == EDeltaType.TrackingField || DeltaType == EDeltaType.NonTrackingField)
{
Format = "#,##0";
}

break;
case ETypeCode.Single:
case ETypeCode.Decimal:
Expand Down

0 comments on commit eedb1a2

Please sign in to comment.