UnitSystem inplementation started, Calculation started
This commit is contained in:
23
UnitSystem/Enums/SystemTypes.cs
Normal file
23
UnitSystem/Enums/SystemTypes.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.UnitSystem.Enums
|
||||
{
|
||||
public enum Force
|
||||
{
|
||||
}
|
||||
public enum Pressure
|
||||
{
|
||||
}
|
||||
public enum Length
|
||||
{
|
||||
M
|
||||
}
|
||||
public enum MultiplyPrefix
|
||||
{
|
||||
m
|
||||
}
|
||||
}
|
||||
14
UnitSystem/Systems/IUnitSystem.cs
Normal file
14
UnitSystem/Systems/IUnitSystem.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using StructureHelper.UnitSystem.Enums;
|
||||
|
||||
namespace StructureHelper.UnitSystem.Systems
|
||||
{
|
||||
public interface IUnitSystem
|
||||
{
|
||||
string Name { get; }
|
||||
Tuple<Force, MultiplyPrefix> ForceUnits { get; }
|
||||
Tuple<Pressure, MultiplyPrefix> PressureUnits { get; }
|
||||
Tuple<Length, MultiplyPrefix> LengthUnits { get; }
|
||||
double ConvertLength(double length);
|
||||
}
|
||||
}
|
||||
29
UnitSystem/Systems/SystemSi.cs
Normal file
29
UnitSystem/Systems/SystemSi.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using StructureHelper.UnitSystem.Enums;
|
||||
using StructureHelper.UnitSystem.Systems;
|
||||
|
||||
namespace StructureHelper.UnitSystem
|
||||
{
|
||||
internal class SystemSi : IUnitSystem
|
||||
{
|
||||
public SystemSi()
|
||||
{
|
||||
LengthUnits = new Tuple<Length, MultiplyPrefix>(Length.M, MultiplyPrefix.m);
|
||||
}
|
||||
|
||||
public string Name => "СИ";
|
||||
public Tuple<Force, MultiplyPrefix> ForceUnits { get; }
|
||||
public Tuple<Pressure, MultiplyPrefix> PressureUnits { get; }
|
||||
public Tuple<Length, MultiplyPrefix> LengthUnits { get; }
|
||||
public double ConvertLength(double length)
|
||||
{
|
||||
switch (LengthUnits.Item2)
|
||||
{
|
||||
case MultiplyPrefix.m:
|
||||
return length / 1000;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
19
UnitSystem/UnitSystemService.cs
Normal file
19
UnitSystem/UnitSystemService.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using StructureHelper.UnitSystem.Systems;
|
||||
|
||||
namespace StructureHelper.UnitSystem
|
||||
{
|
||||
public class UnitSystemService
|
||||
{
|
||||
private IUnitSystem currentSystem;
|
||||
public IUnitSystem GetCurrentSystem() => currentSystem;
|
||||
public UnitSystemService()
|
||||
{
|
||||
currentSystem = new SystemSi();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user