/// <summary> /// find an enumerated DialogAudio that matches the serialized form present in a provided LocalSettings value. /// </summary> /// <param name="settingsValue"> A serialized DialogAudio object from LocalSettings data. </param> /// <returns> A reference to the matching DialogAudio object. Null if not found. </returns> public static DialogAudio GetFromSettingsValue(ApplicationDataCompositeValue settingsValue) { bool Matches <T>(string key, T value) where T : IEquatable <T> => settingsValue.Keys.Contains(key) && Equals(settingsValue[key], value); var dialogAudio = AllFormats.FirstOrDefault(format => Matches <string>(KeyForSubtype, format.Encoding.Subtype) && Matches <uint>(KeyForSampleRate, format.Encoding.SampleRate) && Matches <uint>(KeyForBitsPerSample, format.Encoding.BitsPerSample) && Matches <uint>(KeyForBitrate, format.Encoding.Bitrate) && Matches <uint>(KeyForChannelCount, format.Encoding.ChannelCount)); return(dialogAudio); }
/// <summary> /// Finds the first enumerated DialogAudio object that matches the provided readable label. /// </summary> /// <param name="label"> The label to match. Case-sensitive. </param> /// <returns> The first match found. Null if not found. </returns> public static DialogAudio GetMatchFromLabel(string label) => AllFormats.FirstOrDefault(format => format.Label == label);