Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

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

additional utility methods (used by the GUI)

parent e201483f
No related branches found
No related tags found
No related merge requests found
......@@ -32,6 +32,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
namespace TUGraz.VectoCommon.Utils
......@@ -215,6 +216,11 @@ namespace TUGraz.VectoCommon.Utils
{
return self.Select(x => x.SI<T>());
}
public static string ToGUIFormat(this double self)
{
return self.ToString(CultureInfo.InvariantCulture);
}
}
public static class FloatExtensionMethods
......@@ -225,4 +231,12 @@ namespace TUGraz.VectoCommon.Utils
return SIBase<T>.Create(value);
}
}
public static class IntegerExtensionMethods
{
public static string ToGUIFormat(this int self)
{
return self.ToString();
}
}
}
\ No newline at end of file
......@@ -641,6 +641,7 @@ namespace TUGraz.VectoCommon.Utils
{
return Val * 3.6;
}
/// <summary>
/// Implements the operator /.
/// </summary>
......@@ -833,8 +834,9 @@ namespace TUGraz.VectoCommon.Utils
/// <param name="val">The value of the SI object.</param>
public static T Create(double val)
{
if (val == 0)
if (val == 0) {
return ZeroPrototype;
}
return Constructor(val);
}
......@@ -2249,5 +2251,10 @@ namespace TUGraz.VectoCommon.Utils
return (Val * outputFactor.Value).ToString("F" + decimals.Value, CultureInfo.InvariantCulture);
}
public string ToGUIFormat()
{
return Val.ToGUIFormat();
}
}
}
\ No newline at end of file
......@@ -51,6 +51,18 @@ namespace TUGraz.VectoCommon.Utils
}
}
public static int ToInt(this string self, int? defaultValue = null)
{
try {
return int.Parse(self, CultureInfo.InvariantCulture);
} catch (FormatException) {
if (defaultValue.HasValue) {
return defaultValue.Value;
}
throw;
}
}
public static bool ToBoolean(this string self)
{
if (string.IsNullOrEmpty(self)) {
......
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