Ejemplo n.º 1
0
 /// <summary>
 /// Contains property guid
 /// </summary>
 /// <param name="key">Looks for a specific key</param>
 /// <returns>True if found</returns>
 public bool Contains(PropertyKey key)
 {
     for (int i = 0; i < Count; i++)
     {
         PropertyKey other = Get(i);
         if ((other.formatId == key.formatId) && (other.propertyId == key.propertyId))
         {
             return true;
         }
     }
     return false;
 }
        void IMMNotificationClient.OnPropertyValueChanged(string deviceId, PropertyKey key)
        {
            InvokeOnSynchronizationContext(() =>
            {
                var handler = DevicePropertyChanged;
                if (handler != null)
                {
                    AudioDevice device = GetDevice(deviceId);
                    if (device == null)
                        return;     // Device was already removed by the time I got here

                    handler(this, new AudioDeviceEventArgs(device));
                }
            });
        }
 internal PropertyStoreProperty(PropertyKey key, PropVariant value)
 {
     _key = key;
     _value = value;
 }
Ejemplo n.º 4
0
        public bool TryGetValue(PropertyKey key, out object value)
        {
            value = null;

            try
            {
                var property = this[key];
                if (property == null || property.IsEmpty)
                    return false;
                
                value = property.Value;
                return true;

            }
            catch (COMException ex)
            {
                const int NoSuchHDevinst = unchecked((int)0xE000020B);

                // Bad installation of driver
                if (ex.HResult == NoSuchHDevinst)
                {
                    return false;
                }

                throw;
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Indexer by guid
 /// </summary>
 /// <param name="key">Property Key</param>
 /// <returns>Property or null if not found</returns>
 public PropertyStoreProperty this[PropertyKey key]
 {
     get
     {
         PropVariant result;
         for (int i = 0; i < Count; i++)
         {
             PropertyKey other = Get(i);
             if ((other.formatId == key.formatId) && (other.propertyId == key.propertyId))
             {
                 Marshal.ThrowExceptionForHR(_underlyingStore.GetValue(ref other, out result));
                 return new PropertyStoreProperty(other, result);
             }
         }
         return null;
     }
 }
 internal PropertyStoreProperty(PropertyKey key, PropVariant value)
 {
     _key   = key;
     _value = value;
 }