DefaultValue and Enum?

Dec 14, 2010 at 7:58 PM

How can I handle this? Here is an example of what I am trying to do"

 

public enum WindowToolbarPosition
        {
            Top,Bottom
        }

[DefaultValue(typeof(WindowToolbarPosition), "Bottom")] 
[JsonProperty(PropertyName = "toolbarPosition", NullValueHandling = NullValueHandling.Ignore, DefaultValueHandling = DefaultValueHandling.Include)] 
[JsonConverter(typeof(StringEnumConverter))] 
public WindowToolbarPosition ToolbarPosition { get; set ; } 
 

When the object gets Serialized the default value is never "Bottom" it is always "Top" any thoughts?

 

Coordinator
Dec 18, 2010 at 11:38 PM

It is writing Top because the property's value is Top.

DefaultValueHandling doesn't do what you think it does.