/// <summary> /// Initializes a new instance of the <see cref="AudioSourceSetting"/> class /// with the source and setting attributes. /// </summary> /// <param name="accessor">The accessor for the property.</param> /// <param name="propertyType">Type of the property.</param> /// <param name="propertyName">Name of the property.</param> /// <param name="attribute">The setting attribute.</param> public AudioSourceSetting(ObjectAccessor accessor, Type propertyType, string propertyName, AudioSourceSettingAttribute attribute) { _accessor = accessor; PropertyName = propertyName; Attribute = attribute; SettingType = propertyType; }
/// <summary> /// Initializes a new instance of the <see cref="AudioSourceSettingKeyValue"/> class /// with the model, setting information and if it was saved. /// </summary> /// <param name="audioSource">The associated <see cref="IInternalAudioSource"/>.</param> /// <param name="source">The setting model.</param> /// <param name="settingAttribute">The <see cref="AudioSourceSettingAttribute"/>.</param> public AudioSourceSettingKeyValue(IInternalAudioSource audioSource, AudioSourceSetting source, AudioSourceSettingAttribute settingAttribute) { _settingAttribute = settingAttribute; _audioSource = audioSource; _originalSource = source; MapSelf(_originalSource, _model); // Model value was deserialized from string maybe so change to correct type source.Value = TypeConvertHelper.ConvertToType(source.Value, SettingType); }
/// <summary> /// Initializes a new instance of the <see cref="AudioSourceSettingVM"/> class /// with the model, setting information and if it was saved, /// </summary> /// <param name="audioSource">The associated <see cref="IInternalAudioSource"/>.</param> /// <param name="model">The <see cref="AudioSource"/>.</param> /// <param name="settingAttribute">The <see cref="AudioSourceSettingAttribute"/>.</param> /// <param name="saved">If this setting was saved.</param> public AudioSourceSettingVM(IInternalAudioSource audioSource, AudioSourceSetting model, AudioSourceSettingAttribute settingAttribute, bool saved = true) : base(model) { _settingAttribute = settingAttribute; _audioSource = audioSource; // Model value was deserialized from string maybe so change to correct type model.Value = TypeConvertHelper.ConvertToType(model.Value, SettingType); // If sensitive data and was not saved from before, don't automatically remember it if (Sensitive && !saved) { Remember = false; } }
public void AudioSourceSettingsUpdated_AudioSourceIsUpdatedInPriority() { var setting1 = new AudioSourceSettingAttribute("test1") { Priority = 10 }; var setting2 = new AudioSourceSettingAttribute("test2") { Priority = 5 }; var setting3 = new AudioSourceSettingAttribute("test3") { Priority = 20 }; _audioSourceMock.SetupAllProperties(); _audioSourceMock.SetupGet(m => m.Settings).Returns(new List <AudioSourceSettingAttribute> { setting1, setting2, setting3 }); var settings = new AudioSourceSettings { Settings = new List <AudioSourceSetting> { new AudioSourceSetting { Name = setting1.Name }, new AudioSourceSetting { Name = setting2.Name }, new AudioSourceSetting { Name = setting3.Name }, } }; var s = new MockSequence(); _audioSourceMock.InSequence(s).SetupSet(source => source[It.Is <string>(x => x == setting3.Name)] = null); _audioSourceMock.InSequence(s).SetupSet(source => source[It.Is <string>(x => x == setting1.Name)] = null); _audioSourceMock.InSequence(s).SetupSet(source => source[It.Is <string>(x => x == setting2.Name)] = null); var vm = new AudioSourceSettingsCollectionViewModel(_audioSourceMock.Object, settings, _messageBus.Object); _audioSourceMock.VerifySet(source => source[setting3.Name] = null); _audioSourceMock.VerifySet(source => source[setting1.Name] = null); _audioSourceMock.VerifySet(source => source[setting2.Name] = null); }