private void InitMap() { foreach (var item in Enum.GetNames(typeof(JT809SubBusinessType))) { JT809SubBusinessType subBusinessType = item.ToEnum <JT809SubBusinessType>(); if (!map.ContainsKey((ushort)subBusinessType)) { JT809BodiesTypeAttribute jT809BodiesTypeAttribute = subBusinessType.GetAttribute <JT809BodiesTypeAttribute>(); if (jT809BodiesTypeAttribute != null) { map.Add((ushort)subBusinessType, jT809BodiesTypeAttribute.JT809BodiesType); } } } }
public void Test1() { var types = Enum.GetNames(typeof(JT809SubBusinessType)); foreach (var item in types) { JT809SubBusinessType jT809SubBusinessType = item.ToEnum <JT809SubBusinessType>(); JT809BodiesTypeAttribute jT809SubBodiesTypeAttribute = jT809SubBusinessType.GetAttribute <JT809BodiesTypeAttribute>(); JT809SubBusinessTypeDescriptionAttribute jT809SubBusinessTypeDescriptionAttribute = jT809SubBusinessType.GetAttribute <JT809SubBusinessTypeDescriptionAttribute>(); if (jT809SubBusinessType == JT809SubBusinessType.None) { Assert.Null(jT809SubBodiesTypeAttribute); Assert.Null(jT809SubBusinessTypeDescriptionAttribute); continue; } Assert.NotNull(jT809SubBusinessTypeDescriptionAttribute.Code); Assert.NotNull(jT809SubBusinessTypeDescriptionAttribute.Name); } }