4 using System.Collections.Generic;
5 using System.ComponentModel;
7 using SiliconStudio.Core.IO;
8 using SiliconStudio.Presentation.Extensions;
10 namespace SiliconStudio.Presentation.Settings
24 : base(name, defaultValue)
29 public override Type Type {
get {
return typeof(T); } }
34 public T DefaultValue {
get {
return (T)DefaultObjectValue; } }
39 public Func<IEnumerable<T>> GetAcceptableValues {
get; set; }
52 profile = profile ?? SettingsService.CurrentProfile;
53 if (profile.GetValue(Name, out value, searchInParentProfile, createInCurrentProfile))
57 throw new KeyNotFoundException(
"Settings key not found");
67 profile = profile ?? SettingsService.CurrentProfile;
68 profile.SetValue(Name, value);
81 profile = profile ?? SettingsService.CurrentProfile;
82 if (profile.GetValue(Name, out obj, searchInParentProfile,
false))
100 internal override object ConvertValue(
object value)
105 var converter = TypeDescriptor.GetConverter(typeof(T));
106 if (converter.CanConvertFrom(value != null ? value.GetType() : typeof(
object)))
108 convertedValue = (T)converter.ConvertFrom(value);
112 convertedValue = (T)
Convert.ChangeType(value, typeof(T));
117 convertedValue = DefaultValue;
119 return convertedValue;
SettingsValueKey(UFile name, T defaultValue)
Initializes a new instance of the SettingsValueKey{T} class.
This class represents a collection of values for all registered SettingsKey. It may also contains val...
void SetValue(T value, SettingsProfile profile=null)
Sets the value of this settings key in the given profile.
This class represents property to store in the settings that is identified by a key.
T GetValue(bool searchInParentProfile=true, SettingsProfile profile=null, bool createInCurrentProfile=false)
Gets the value of this settings key in the given profile.
HRESULT Convert(_In_ const Image &srcImage, _In_ DXGI_FORMAT format, _In_ DWORD filter, _In_ float threshold, _Out_ ScratchImage &image)
bool TryGetValue(out T value, bool searchInParentProfile=true, SettingsProfile profile=null)
Tries to gets the value of this settings key in the given profile, if it exists.
Defines a normalized file path. See UPath for details. This class cannot be inherited.