using System;
using NvAPIWrapper.Native.DRS;
using NvAPIWrapper.Native.DRS.Structures;
namespace NvAPIWrapper.DRS
{
///
/// Represents a profile setting and its value
///
public class ProfileSetting
{
private readonly DRSSettingV1 _setting;
internal ProfileSetting(DRSSettingV1 setting)
{
_setting = setting;
}
///
/// Gets the current value of the setting
///
public object CurrentValue
{
get
{
if (IsPredefinedValueValid && IsCurrentValuePredefined)
{
return _setting.PredefinedValue;
}
return _setting.CurrentValue;
}
}
///
/// Gets a boolean value indicating if the current value is the predefined value.
///
public bool IsCurrentValuePredefined
{
get => _setting.IsCurrentValuePredefined;
}
///
/// Gets a boolean value indicating if this setting had a predefined valid value.
///
public bool IsPredefinedValueValid
{
get => _setting.IsPredefinedValueValid;
}
///
/// Gets the predefined value of this setting.
///
public object PredefinedValue
{
get
{
if (!IsPredefinedValueValid)
{
throw new InvalidOperationException("Predefined value is not valid.");
}
return _setting.PredefinedValue;
}
}
///
/// Gets the setting identification number
///
public uint SettingId
{
get => _setting.Id;
}
///
/// Gets additional information regarding this setting including possible valid values
///
public SettingInfo SettingInfo
{
get => SettingInfo.FromId(SettingId);
}
///
/// Gets the profile location of this setting
///
public DRSSettingLocation SettingLocation
{
get => _setting.SettingLocation;
}
///
/// Gets the value type of this setting
///
public DRSSettingType SettingType
{
get => _setting.SettingType;
}
///
public override string ToString()
{
string settingName = null;
try
{
settingName = SettingInfo.Name;
}
catch
{
// ignore;
}
if (string.IsNullOrWhiteSpace(settingName))
{
settingName = $"#{SettingId:X}";
}
if (IsCurrentValuePredefined)
{
return $"{settingName} = {CurrentValue ?? "[NULL]"} (Predefined)";
}
return $"{settingName} = {CurrentValue ?? "[NULL]"}";
}
}
}