lixiaojun
2024-11-08 adf7734a40dec76fc31590906eeadd02c782db90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
namespace Yw.WinFrmUI
{
    internal class HydroFlowDirectionHelper
    {
        //字典
        private static readonly Dictionary<int, string> _dict = new Dictionary<int, string>()
        {
            { Yw.Hydro.FlowDirection.None,"无"},
            { Yw.Hydro.FlowDirection.Positive,"正"},
            { Yw.Hydro.FlowDirection.Negative,"反"}
        };
 
        /// <summary>
        /// 获取名称
        /// </summary>
        public static string GetName(int code)
        {
            if (_dict.ContainsKey(code))
            {
                return _dict[code];
            }
            return string.Empty;
        }
 
        /// <summary>
        /// 获取编码
        /// </summary>
        public static int GetCode(string name)
        {
            if (_dict.ContainsValue(name))
            {
                return _dict.First(x => x.Value == name).Key;
            }
            return Yw.Hydro.FlowDirection.None;
        }
 
    }
}