Skip to content

Commit

Permalink
Fixed DataBinding issues
Browse files Browse the repository at this point in the history
  • Loading branch information
RNoeldner committed Mar 23, 2023
1 parent 60b6f02 commit bae0b82
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 74 deletions.
30 changes: 15 additions & 15 deletions Application/FormEditSettings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Library/ClassLibraryCSV/ClassLibraryCsvExtensionMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ public static string PlaceholderReplace(this string input, in string placeholder
return input.ReplaceCaseInsensitive(type, replacement);
}

public static string PlaceholderReplaceFormat(this string input, string placeholder, DateTime dateTime)
public static string PlaceholderReplaceFormat(this string input, string placeholder, in string formatedDateTime )
{
// in case we have a placeholder with a formatting part e.G. {date:yyyy-MM-dd} we us
// string.Format to process {0:...
Expand All @@ -546,8 +546,8 @@ public static string PlaceholderReplaceFormat(this string input, string placehol
RegexOptions.IgnoreCase | RegexOptions.Singleline);

return !regEx.IsMatch(input)
? PlaceholderReplace(input, placeholder, dateTime.ToString(CultureInfo.CurrentCulture))
: string.Format(regEx.Replace(input, "{0$2}"), dateTime.ToString(CultureInfo.CurrentCulture));
? PlaceholderReplace(input, placeholder, formatedDateTime)
: string.Format(regEx.Replace(input, "{0$2}"), formatedDateTime);
}

/// <summary>
Expand Down
7 changes: 5 additions & 2 deletions Library/ClassLibraryCSV/FileSystemUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#nullable enable

using System;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
Expand Down Expand Up @@ -563,8 +564,10 @@ public static string RemovePrefix(this string path)
return string.Empty;

// Handle date Placeholders
fileName = fileName.PlaceholderReplaceFormat("date", DateTime.Now)
.PlaceholderReplaceFormat("utc", DateTime.UtcNow);
fileName = fileName.PlaceholderReplaceFormat("date", DateTime.Now.ToString(CultureInfo.CurrentCulture))
.PlaceholderReplaceFormat("utc", DateTime.UtcNow.ToString(CultureInfo.CurrentCulture))
.PlaceholderReplace("CDate", string.Format(new CultureInfo("en-US"), "{0:dd-MMM-yyyy}", DateTime.Now))
.PlaceholderReplace("CDateLong", string.Format(new CultureInfo("en-US"), "{0:MMMM dd\\, yyyy}", DateTime.Now)) ?? string.Empty;

// only if we have wildcards carry on
if (fileName.IndexOfAny(new[] { '*', '?', '[', ']' }) == -1)
Expand Down
64 changes: 10 additions & 54 deletions Library/ClassLibraryCSV/ValueFormat/ValueFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,69 +69,25 @@ public ValueFormat(
string? fileOutPutPlaceholder = "",
bool? overwrite = cOverwriteDefault)
{
// Set defaults
DataType = dataType ?? DataTypeEnum.String;

DateFormat = cDateFormatDefault;
DateSeparator = cDateSeparatorDefaultChar;
TimeSeparator = cTimeSeparatorDefaultChar;
NumberFormat = cNumberFormatDefault;
DecimalSeparator = cDecimalSeparatorDefaultChar;
GroupSeparator = cGroupSeparatorDefaultChar;

// Boolean
False = asFalse ?? cFalseDefault;
True = asTrue ?? cTrueDefault;

Part = cPartDefault;
PartSplitter = cPartSplitterDefaultChar;
PartToEnd = cPartToEndDefault;
// Text
DisplayNullAs = displayNullAs ?? string.Empty;

// Regex
RegexSearchPattern = regexSearchPattern ?? string.Empty;
RegexReplacement = regexReplacement ?? string.Empty;

// Binary writer
ReadFolder = readFolder ?? string.Empty;
WriteFolder = writeFolder ?? string.Empty;
FileOutPutPlaceholder = fileOutPutPlaceholder ?? string.Empty;
Overwrite = cOverwriteDefault;

// Depending on type set the other corresponding values
// Json Serializer does ignore defaults in ctor
if (DataTypeEnum.DateTime.Equals(dataType))
{
// Dates
DateFormat = dateFormat ?? cDateFormatDefault;
DateSeparator = (dateSeparator ?? cDateSeparatorDefault).FromText();
TimeSeparator = (timeSeparator ?? cTimeSeparatorDefault).FromText();
}
else if (DataTypeEnum.Integer.Equals(dataType))
{
NumberFormat = numberFormat ?? cNumberFormatDefault;
GroupSeparator = (groupSeparator ?? cGroupSeparatorDefault).FromText();
}
else if (DataTypeEnum.Numeric.Equals(dataType) || DataTypeEnum.Double.Equals(dataType))
{
// Numbers
NumberFormat = numberFormat ?? cNumberFormatDefault;
DecimalSeparator = (decimalSeparator ?? cDecimalSeparatorDefault).FromText();
GroupSeparator = (groupSeparator ?? cGroupSeparatorDefault).FromText();
}
else if (DataTypeEnum.TextPart.Equals(dataType))
{
// TextPart
Part = part ?? cPartDefault;
PartSplitter = (partSplitter ?? cPartSplitterDefault).FromText();
PartToEnd = partToEnd ?? cPartToEndDefault;
}
else if (DataTypeEnum.Binary.Equals(dataType))
{
// Binary writer
Overwrite = overwrite ?? cOverwriteDefault;
}
DateFormat = dateFormat ?? cDateFormatDefault;
DateSeparator = (dateSeparator ?? cDateSeparatorDefault).FromText();
TimeSeparator = (timeSeparator ?? cTimeSeparatorDefault).FromText();
NumberFormat = numberFormat ?? cNumberFormatDefault;
GroupSeparator = (groupSeparator ?? cGroupSeparatorDefault).FromText();
DecimalSeparator = (decimalSeparator ?? cDecimalSeparatorDefault).FromText();
Part = part ?? cPartDefault;
PartSplitter = (partSplitter ?? cPartSplitterDefault).FromText();
PartToEnd = partToEnd ?? cPartToEndDefault;
Overwrite = overwrite ?? cOverwriteDefault;
}

/// <summary>
Expand Down

0 comments on commit bae0b82

Please sign in to comment.