public ExifPropertyInfo From(PropertyItemEncoded propertyItem) { string decodeValue = null; //find property var matchedProperty = FindPropertyMatch(propertyItem); //no match. no property. I'm done with you. if (matchedProperty == null) return null; //need to explicitly convert values to a string to be a consistent type for all values var convertedValue = _propertyItemValueConverter.From(propertyItem.Type, propertyItem.Value); //does the value need to be translated from predefined codes? if (matchedProperty.HasElements) decodeValue = DecodeValue(matchedProperty, convertedValue); var propertyInfo = new ExifPropertyInfo() { Name = matchedProperty.Attribute("name").Value, ShortName = matchedProperty.Attribute("shortname").Value, Value = string.IsNullOrEmpty(decodeValue) ? convertedValue.ToString() : decodeValue }; return propertyInfo; }
private XElement FindPropertyMatch(PropertyItemEncoded propertyItem) { return _exifProperties.FirstOrDefault(x => x.Attribute("dec").Value.Equals(propertyItem.Id.ToString()) || x.Attribute("hex").Value.Equals(propertyItem.Id.ToString())); }