4 using System.Collections;
5 using System.Collections.Generic;
6 using System.ComponentModel;
7 using System.Globalization;
10 using SiliconStudio.Core.IO;
12 namespace SiliconStudio.Presentation.Settings
26 : base(name, defaultValue.ToList())
28 if (defaultValue == null)
throw new ArgumentNullException(
"defaultValue");
32 public override Type Type {
get {
return typeof(
IList<T>); } }
49 profile = profile ?? SettingsService.CurrentProfile;
51 if (profile.GetValue(Name, out value, searchInParentProfile, createInCurrentProfile))
60 throw new KeyNotFoundException(
"Settings key not found");
72 profile = profile ?? SettingsService.CurrentProfile;
74 if (profile.GetValue(Name, out value, searchInParentProfile,
false))
84 internal override object ConvertValue(
object value)
86 var result =
new List<T>();
89 var list = value as IList;
93 foreach (
object item
in list)
95 var converter = TypeDescriptor.GetConverter(typeof(T));
97 if (converter.CanConvertFrom(item != null ? item.GetType() : typeof(
object)))
99 newValue = (T)converter.ConvertFrom(item);
103 newValue = (T)
Convert.ChangeType(item, typeof(T));
105 result.Add(newValue);
110 result =
new List<T>(DefaultValue);
bool TryGetList(out IList< T > list, bool searchInParentProfile=true, SettingsProfile profile=null)
Tries to gets the list of values of this settings key in the current profile.
This class represents a collection of values for all registered SettingsKey. It may also contains val...
This class represents property to store in the settings that is identified by a key.
SettingsListKey(UFile name, IEnumerable< T > defaultValue)
Initializes a new instance of the SettingsListKey{T} class.
HRESULT Convert(_In_ const Image &srcImage, _In_ DXGI_FORMAT format, _In_ DWORD filter, _In_ float threshold, _Out_ ScratchImage &image)
Defines a normalized file path. See UPath for details. This class cannot be inherited.
IList< T > GetList(bool searchInParentProfile=true, SettingsProfile profile=null, bool createInCurrentProfile=false)
Gets the list of values of this settings key in the current profile.