Skip to content

Commit

Permalink
PR feedback 1
Browse files Browse the repository at this point in the history
  • Loading branch information
campersau committed Feb 10, 2022
1 parent 5790dcb commit 174c643
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 28 deletions.
12 changes: 0 additions & 12 deletions src/SapNwRfc/Internal/Fields/DateField.cs
Expand Up @@ -19,12 +19,7 @@ public DateField(string name, DateTime? value)

public override void Apply(RfcInterop interop, IntPtr dataHandle)
{
#if NETSTANDARD2_0
char[] buffer = (Value?.ToString(RfcDateFormat, CultureInfo.InvariantCulture) ?? ZeroRfcDateString).ToCharArray();
#else
char[] buffer = ZeroRfcDateString.ToCharArray();
Value?.TryFormat(buffer, out var _, RfcDateFormat, CultureInfo.InvariantCulture);
#endif

RfcResultCode resultCode = interop.SetDate(
dataHandle: dataHandle,
Expand All @@ -47,17 +42,10 @@ public static DateField Extract(RfcInterop interop, IntPtr dataHandle, string na

resultCode.ThrowOnError(errorInfo);

#if NETSTANDARD2_0
string dateString = new string(buffer);

if (dateString == EmptyRfcDateString || dateString == ZeroRfcDateString)
return new DateField(name, null);
#else
Span<char> dateString = buffer.AsSpan();

if (dateString.SequenceEqual(EmptyRfcDateString) || dateString.SequenceEqual(ZeroRfcDateString))
return new DateField(name, null);
#endif

if (!DateTime.TryParseExact(dateString, RfcDateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime date))
return new DateField(name, null);
Expand Down
4 changes: 0 additions & 4 deletions src/SapNwRfc/Internal/Fields/DecimalField.cs
Expand Up @@ -54,11 +54,7 @@ public static DecimalField Extract(RfcInterop interop, IntPtr dataHandle, string

resultCode.ThrowOnError(errorInfo);

#if NETSTANDARD2_0
var decimalValue = decimal.Parse(new string(buffer, 0, (int)stringLength), CultureInfo.InvariantCulture);
#else
var decimalValue = decimal.Parse(buffer.AsSpan(), provider: CultureInfo.InvariantCulture);
#endif

return new DecimalField(name, decimalValue);
}
Expand Down
12 changes: 0 additions & 12 deletions src/SapNwRfc/Internal/Fields/TimeField.cs
Expand Up @@ -19,12 +19,7 @@ public TimeField(string name, TimeSpan? value)

public override void Apply(RfcInterop interop, IntPtr dataHandle)
{
#if NETSTANDARD2_0
char[] buffer = (Value?.ToString(RfcTimeFormat, CultureInfo.InvariantCulture) ?? ZeroRfcTimeString).ToCharArray();
#else
char[] buffer = ZeroRfcTimeString.ToCharArray();
Value?.TryFormat(buffer, out var _, RfcTimeFormat, CultureInfo.InvariantCulture);
#endif

RfcResultCode resultCode = interop.SetTime(
dataHandle: dataHandle,
Expand All @@ -47,17 +42,10 @@ public static TimeField Extract(RfcInterop interop, IntPtr dataHandle, string na

resultCode.ThrowOnError(errorInfo);

#if NETSTANDARD2_0
string timeString = new string(buffer);

if (timeString == EmptyRfcTimeString || timeString == ZeroRfcTimeString)
return new TimeField(name, null);
#else
Span<char> timeString = buffer.AsSpan();

if (timeString.SequenceEqual(EmptyRfcTimeString) || timeString.SequenceEqual(ZeroRfcTimeString))
return new TimeField(name, null);
#endif

if (!TimeSpan.TryParseExact(timeString, RfcTimeFormat, CultureInfo.InvariantCulture, out TimeSpan time))
return new TimeField(name, null);
Expand Down

0 comments on commit 174c643

Please sign in to comment.