Edition of primitives is changed

This commit is contained in:
Evgeny Redikultsev
2022-10-30 18:58:51 +05:00
parent 87a42efc24
commit e1af4d5e07
48 changed files with 1198 additions and 146 deletions

View File

@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace StructureHelper.Infrastructure.UI.Converters.Units
{
internal class Length : UnitBase
{
public override string unitName { get => "Length"; }
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
double val;
if (value != null) { val = (double)value; }
else { throw new Exception($"{unitName} value is null"); }
val *= UnitConstatnts.LengthConstant;
return val;
}
public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
double val;
if (value != null)
{
var strVal = value as string;
double.TryParse(strVal, out val);
}
else { throw new Exception($"{unitName} value is null"); }
val /= UnitConstatnts.LengthConstant;
return val;
}
}
}