public static ExifItem Convert(this PropertyItem item) { if (!Items.TryGetValue(item.Id, out ExifItem result)) { result = new ExifItem(); result.Id = item.Id; } DataType type = (DataType)item.Type; result.DataType = type; object value = item.Value.GetSpecifiedFormatObject(type, item.Len); if (value is string str) { if (str.EndsWith("\0")) { result.Value = str.Substring(0, str.Length - 1); } else { result.Value = value; } } else { result.Value = value; } result.Length = item.Len; return(result); }
public static string ConvertValue(ExifItem item) { if (Converters.ContainsKey(item.Id)) { return(Converters[item.Id](item.Value)); } throw new Exception("不存在ID为" + item.Id + "的转换器"); }
public static string TryConvertValue(ExifItem item) { if (!Converters.ContainsKey(item.Id)) { return(null); } try { return(ConvertValue(item)); } catch (Exception ex) { return(null); } }