Skip to content

Commit

Permalink
Fixed conversion of default values.
Browse files Browse the repository at this point in the history
  • Loading branch information
pruiz committed Dec 24, 2015
1 parent 96d09e4 commit a49bb62
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions HermaFx.Castle/DictionaryAdapter/AppSettingsAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ public object GetPropertyValue(IDictionaryAdapter dictionaryAdapter, string key,
}
else if (defaultValue != null)
{
storedValue = defaultValue.Value;
var @default = defaultValue.Value;
storedValue = descriptor.TypeConverter.CanConvertFrom(@default.GetType()) ?
descriptor.TypeConverter.ConvertFrom(@default)
: Convert.ChangeType(@default, descriptor.PropertyType);
}
}

Expand Down Expand Up @@ -187,13 +190,15 @@ public void Invalidate(IDictionaryAdapter dictionaryAdapter)
#endregion
#endif

#if false
#if true
public static class Test
{
[AppSettings("A")]
public interface A
{
string Data { get; set; }
[DefaultValue(10)]
uint Number { get; set; }
}

[AppSettings("B")]
Expand Down

0 comments on commit a49bb62

Please sign in to comment.