using System;
|
using System.Collections.Generic;
|
|
namespace IStation.Unit
|
{
|
/// <summary>
|
/// 电压单位辅助类
|
/// </summary>
|
public class UnitVoltageHelper : IUnitHelper
|
{
|
#region 静态
|
|
public static double Convert(eUnitVoltage fromUnit, eUnitVoltage toUnit, double fromValue)
|
{
|
return fromValue;
|
}
|
|
public static string GetCnUnitName(eUnitVoltage unit)
|
{
|
switch (unit)
|
{
|
case eUnitVoltage.V: return "伏";
|
|
default: return string.Empty;
|
}
|
|
}
|
|
public static List<string> GetCnUnitNameList()
|
{
|
var list = new List<string>();
|
foreach (eUnitVoltage item in Enum.GetValues(typeof(eUnitVoltage)))
|
{
|
list.Add(GetCnUnitName(item));
|
}
|
return list;
|
}
|
|
public static Dictionary<eUnitVoltage, string> GetCnUnitDict()
|
{
|
var dic = new Dictionary<eUnitVoltage, string>();
|
foreach (eUnitVoltage item in Enum.GetValues(typeof(eUnitVoltage)))
|
{
|
dic.Add(item, GetCnUnitName(item));
|
}
|
return dic;
|
}
|
|
public static string GetEnUnitName(eUnitVoltage unit)
|
{
|
switch (unit)
|
{
|
case eUnitVoltage.V: return "V";
|
|
default: return string.Empty;
|
}
|
}
|
|
|
|
|
public static List<string> GetEnUnitNameList()
|
{
|
var list = new List<string>();
|
foreach (eUnitVoltage item in Enum.GetValues(typeof(eUnitVoltage)))
|
{
|
list.Add(GetEnUnitName(item));
|
}
|
return list;
|
}
|
|
|
|
|
public static Dictionary<eUnitVoltage, string> GetEnUnitDict()
|
{
|
var dic = new Dictionary<eUnitVoltage, string>();
|
foreach (eUnitVoltage item in Enum.GetValues(typeof(eUnitVoltage)))
|
{
|
dic.Add(item, GetEnUnitName(item));
|
}
|
return dic;
|
}
|
|
|
|
|
#endregion
|
|
#region 显示接口
|
|
|
double IUnitHelper.Convert(int fromUnit, int toUnit, double fromValue)
|
{
|
return Convert((eUnitVoltage)fromUnit, (eUnitVoltage)toUnit, fromValue);
|
}
|
|
string IUnitHelper.GetCnUnitName(int unit)
|
{
|
return GetCnUnitName((eUnitVoltage)unit);
|
}
|
|
List<string> IUnitHelper.GetCnUnitNameList()
|
{
|
return GetCnUnitNameList();
|
}
|
|
Dictionary<int, string> IUnitHelper.GetCnUnitDict()
|
{
|
var dic = new Dictionary<int, string>();
|
foreach (var item in GetCnUnitDict())
|
{
|
dic.Add((int)item.Key, item.Value);
|
}
|
return dic;
|
}
|
|
string IUnitHelper.GetEnUnitName(int unit)
|
{
|
return GetEnUnitName((eUnitVoltage)unit);
|
}
|
|
List<string> IUnitHelper.GetEnUnitNameList()
|
{
|
return GetEnUnitNameList();
|
}
|
|
Dictionary<int, string> IUnitHelper.GetEnUnitDict()
|
{
|
var dic = new Dictionary<int, string>();
|
foreach (var item in GetEnUnitDict())
|
{
|
dic.Add((int)item.Key, item.Value);
|
}
|
return dic;
|
}
|
|
|
|
|
#endregion
|
}
|
}
|