/// <summary>
        /// Retrieves the metadata block or item identified by a metadata query expression.
        /// </summary>
        /// <param name="name">The query expression to the requested metadata block or item.</param>
        /// <param name="value">The metadata block or item requested or null if not found.</param>
        /// <returns>True when the metadata block or item was found, otherwise false.</returns>
        /// <remarks>
        /// GetMetadataByName uses metadata query expressions to access embedded metadata. For more information on the metadata query language, see the Metadata Query Language Overview.
        /// <br/>
        /// If multiple blocks or items exist that are expressed by the same query expression, the first metadata block or item found will be returned.
        /// </remarks>
        public static bool TryGetMetadataByName(this IWICMetadataQueryReader metadataQueryReader, string name, out object?value)
        {
            if (metadataQueryReader is null)
            {
                throw new NullReferenceException();
            }
            if (name is null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            var variant = new PROPVARIANT();

            try
            {
                metadataQueryReader.GetMetadataByName(name, ref variant);
                value = PropVariantHelper.Decode(variant);
                return(true);
            }
            catch (COMException ex) when(ex.ErrorCode == WinCodecError.PROPERTY_NOT_FOUND)
            {
                value = null;
                return(false);
            }
            finally
            {
                PropVariantHelper.Free(variant);
            }
        }
        /// <summary>
        /// Retrieves the metadata block or item identified by a metadata query expression.
        /// </summary>
        /// <param name="name">The query expression to the requested metadata block or item.</param>
        /// <returns>The metadata block or item requested.</returns>
        /// <exception cref="COMException">Thrown when the metadata block or item was not found (HRESULT 0x88982F40).</exception>
        /// <remarks>
        /// GetMetadataByName uses metadata query expressions to access embedded metadata. For more information on the metadata query language, see the Metadata Query Language Overview.
        /// <br/>
        /// If multiple blocks or items exist that are expressed by the same query expression, the first metadata block or item found will be returned.
        /// </remarks>
        public static object GetMetadataByName(this IWICMetadataQueryReader metadataQueryReader, string name)
        {
            if (metadataQueryReader is null)
            {
                throw new NullReferenceException();
            }
            if (name is null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            var variant = new PROPVARIANT();

            try
            {
                metadataQueryReader.GetMetadataByName(name, ref variant);
                return(PropVariantHelper.Decode(variant));
            }
            finally
            {
                PropVariantHelper.Free(variant);
            }
        }