Skip to content

Commit

Permalink
removed old extension methods, corrected datetime param handling
Browse files Browse the repository at this point in the history
  • Loading branch information
erlendoksvoll committed Jan 12, 2024
1 parent dcea212 commit d16c41e
Showing 1 changed file with 1 addition and 32 deletions.
33 changes: 1 addition & 32 deletions Dan.Common/Extensions/EvidenceHarvesterRequestExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static bool TryGetParameter(this EvidenceHarvesterRequest ehr, string par
return false;
}

return DateTime.TryParse((string?)parameter?.Value, out value);
return DateTime.TryParse(parameter?.Value.ToString(), out value);

Check warning on line 78 in Dan.Common/Extensions/EvidenceHarvesterRequestExtension.cs

View workflow job for this annotation

GitHub Actions / run / build

Dereference of a possibly null reference.

Check warning on line 78 in Dan.Common/Extensions/EvidenceHarvesterRequestExtension.cs

View workflow job for this annotation

GitHub Actions / run / build

Dereference of a possibly null reference.

Check warning on line 78 in Dan.Common/Extensions/EvidenceHarvesterRequestExtension.cs

View workflow job for this annotation

GitHub Actions / run / build

Dereference of a possibly null reference.

Check warning on line 78 in Dan.Common/Extensions/EvidenceHarvesterRequestExtension.cs

View workflow job for this annotation

GitHub Actions / run / build

Dereference of a possibly null reference.

Check warning on line 78 in Dan.Common/Extensions/EvidenceHarvesterRequestExtension.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 78 in Dan.Common/Extensions/EvidenceHarvesterRequestExtension.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 78 in Dan.Common/Extensions/EvidenceHarvesterRequestExtension.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 78 in Dan.Common/Extensions/EvidenceHarvesterRequestExtension.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
}


Expand Down Expand Up @@ -109,35 +109,4 @@ public static bool TryGetParameter(this EvidenceHarvesterRequest ehr, string par
parameter = ehr.Parameters?.FirstOrDefault(x => x.EvidenceParamName == paramName);
return parameter != null;
}

/// <summary>
/// Gets a parameter value as the requested type if set
/// </summary>
/// <remarks>This is deprecated. Use TryGetParameter instead</remarks>
/// <typeparam name="T">The requested type to attempt to cast the value to</typeparam>
/// <param name="ehr">The evidence harvester request</param>
/// <param name="paramName">The parameter name</param>
/// <returns>The parameter value</returns>
public static T? GetParameterValue<T>(this EvidenceHarvesterRequest ehr, string paramName)
{
return (T?)ehr.GetParameter(paramName).Value;
}

/// <summary>
/// Gets a parameter if set
/// </summary>
/// /// <remarks>This is deprecated. Use TryGetParameter instead</remarks>
/// <param name="ehr">The evidence harvester request</param>
/// <param name="paramName">The parameter name</param>
/// <returns>The parameter</returns>
public static EvidenceParameter GetParameter(this EvidenceHarvesterRequest ehr, string paramName)
{
var param = ehr.Parameters?.FirstOrDefault(x => x.EvidenceParamName == paramName);
if (param == null)
{
throw new ArgumentNullException($"The parameter {paramName} was not provided");
}

return param;
}
}

0 comments on commit d16c41e

Please sign in to comment.