Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 90063317 authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

store si-unit string on validation and use for error message

parent d2fdcea5
No related branches found
No related tags found
No related merge requests found
......@@ -198,6 +198,7 @@ namespace TUGraz.VectoCommon.Utils
public class SIRangeAttribute : RangeAttribute
{
private ExecutionMode? _mode;
private string _unit = "-";
/// <summary>
/// Checks the Min-Max Range of SI Objects.
......@@ -267,6 +268,10 @@ namespace TUGraz.VectoCommon.Utils
{
var si = value as SI;
if (si != null) {
_unit = si.GetUnitString();
}
var modeService = validationContext.GetService(typeof(ExecutionMode)) as ExecutionModeServiceContainer;
var mode = modeService == null ? (ExecutionMode?)null : modeService.Mode;
if (mode == null) {
......@@ -277,6 +282,13 @@ namespace TUGraz.VectoCommon.Utils
}
return ValidationResult.Success;
}
public override string FormatErrorMessage(string name)
{
const string unitString = "{0} [{1}]";
return string.Format(ErrorMessageString, name, string.Format(unitString, Minimum, _unit),
string.Format(unitString, Maximum, _unit));
}
}
/// <summary>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment