private static void ProcessXmpTag([NotNull] IXmpMeta meta, [NotNull] XmpDirectory directory, int tagType, FormatType formatCode)
        {
            string schemaNs;
            string propName;

            if (!XmpDirectory.TagSchemaMap.TryGetValue(tagType, out schemaNs) || !XmpDirectory.TagPropNameMap.TryGetValue(tagType, out propName))
            {
                return;
            }

            var property = meta.GetPropertyString(schemaNs, propName);

            if (property == null)
            {
                return;
            }

            switch (formatCode)
            {
            case FormatType.Rational:
            {
                // TODO introduce Rational.TryParse
                var rationalParts = property.Split('/').Take(2).ToArray();
                if (rationalParts.Length == 2)
                {
                    // TODO should this really be parsed as float?
                    float numerator;
                    float denominator;
                    if (float.TryParse(rationalParts[0], out numerator) && float.TryParse(rationalParts[1], out denominator))
                    {
                        directory.Set(tagType, new Rational((long)numerator, (long)denominator));
                    }
                    else
                    {
                        directory.AddError($"Unable to parse XMP property {propName} as a Rational.");
                    }
                }
                else
                {
                    directory.AddError($"Error in rational format for tag {tagType}");
                }
                break;
            }

            case FormatType.Int:
            {
                int value;
                if (int.TryParse(property, out value))
                {
                    directory.Set(tagType, value);
                }
                else
                {
                    directory.AddError($"Unable to parse XMP property {propName} as an int.");
                }
                break;
            }

            case FormatType.Double:
            {
                double value;
                if (double.TryParse(property, out value))
                {
                    directory.Set(tagType, value);
                }
                else
                {
                    directory.AddError($"Unable to parse XMP property {propName} as a double.");
                }
                break;
            }

            case FormatType.String:
            {
                directory.Set(tagType, property);
                break;
            }

            case FormatType.StringArray:
            {
                // XMP iterators are 1-based
                var count = meta.CountArrayItems(schemaNs, propName);
                var array = new string[count];
                for (var i = 1; i <= count; i++)
                {
                    array[i - 1] = meta.GetArrayItem(schemaNs, propName, i).Value;
                }
                directory.Set(tagType, array);
                break;
            }

            default:
            {
                directory.AddError($"Unknown format code {formatCode} for tag {tagType}");
                break;
            }
            }
        }
        /// <summary>Reads an property value with given namespace URI and property name.</summary>
        /// <remarks>Reads an property value with given namespace URI and property name. Add property value to directory if exists</remarks>
        /// <exception cref="XmpException"/>
        private static void ProcessXmpTag([NotNull] IXmpMeta meta, [NotNull] XmpDirectory directory, int tagType, FormatType formatCode)
        {
            string schemaNs;
            string propName;

            if (!XmpDirectory.TagSchemaMap.TryGetValue(tagType, out schemaNs) || !XmpDirectory.TagPropNameMap.TryGetValue(tagType, out propName))
            {
                return;
            }

            var property = meta.GetPropertyString(schemaNs, propName);

            if (property == null)
            {
                return;
            }

            switch (formatCode)
            {
            case FormatType.Rational:
            {
                var rationalParts = property.Split(new[] { '/' }, 2);
                if (rationalParts.Length == 2)
                {
                    try
                    {
                        var rational = new Rational((long)float.Parse(rationalParts[0]), (long)float.Parse(rationalParts[1]));
                        directory.Set(tagType, rational);
                    }
                    catch (FormatException)
                    {
                        directory.AddError($"Unable to parse XMP property {propName} as a Rational.");
                    }
                }
                else
                {
                    directory.AddError("Error in rational format for tag " + tagType);
                }
                break;
            }

            case FormatType.Int:
            {
                try
                {
                    directory.Set(tagType, int.Parse(property));
                }
                catch (FormatException)
                {
                    directory.AddError($"Unable to parse XMP property {propName} as an int.");
                }
                break;
            }

            case FormatType.Double:
            {
                try
                {
                    directory.Set(tagType, double.Parse(property));
                }
                catch (FormatException)
                {
                    directory.AddError($"Unable to parse XMP property {propName} as an double.");
                }
                break;
            }

            case FormatType.String:
            {
                directory.Set(tagType, property);
                break;
            }

            case FormatType.StringArray:
            {
                //XMP iterators are 1-based
                var count = meta.CountArrayItems(schemaNs, propName);
                var array = new string[count];
                for (var i = 1; i <= count; ++i)
                {
                    array[i - 1] = meta.GetArrayItem(schemaNs, propName, i).Value;
                }
                directory.Set(tagType, array);
                break;
            }

            default:
            {
                directory.AddError($"Unknown format code {formatCode} for tag {tagType}");
                break;
            }
            }
        }