Esempio n. 1
0
        public static object GetUnknown(this IMFAttributes input, Guid key, Guid interfaceId)
        {
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            if (input.GetUnknown(key, interfaceId, out var value).IsError)
            {
                return(null);
            }

            return(value);
        }
Esempio n. 2
0
        public static ComObject <T> GetUnknown <T>(this IMFAttributes obj, Guid key, Guid interfaceId)
        {
            if (obj == null)
            {
                throw new ArgumentNullException(nameof(obj));
            }

            if (obj.GetUnknown(key, interfaceId, out var value).IsError)
            {
                return(null);
            }

            return(new ComObject <T>((T)value));
        }
        /// <summary>
        /// Retrieves a COM instance associated with a key.
        /// </summary>
        /// <typeparam name="T">The requested COM interface.</typeparam>
        /// <param name="attributes">A valid IMFAttributes instance.</param>
        /// <param name="guidKey">Guid that identifies which value to retrieve.</param>
        /// <param name="obj">Receives the requested COM instance.</param>
        /// <returns>If this function succeeds, it returns the S_OK member. Otherwise, it returns another HResult's member that describe the error.</returns>
        public static HResult GetUnknown <T>(this IMFAttributes attributes, Guid guidKey, out T obj) where T : class
        {
            if (attributes == null)
            {
                throw new ArgumentNullException("attributes");
            }

            Type typeOfT = typeof(T);

            if (!typeOfT.IsComInterface())
            {
                throw new ArgumentOutOfRangeException("T", "T must be a COM visible interface.");
            }

            object tmp;

            HResult hr = attributes.GetUnknown(guidKey, typeOfT.GUID, out tmp);

            obj = hr.Succeeded() ? tmp as T : null;

            return(hr);
        }
Esempio n. 4
0
 public HResult GetUnknown(Guid guidKey, Guid riid, out object ppv)
 {
     return(m_Attribs.GetUnknown(guidKey, riid, out ppv));
 }