Last active
August 29, 2015 14:00
-
-
Save elutsky/11361196 to your computer and use it in GitHub Desktop.
ToJson() extension method serialization order with ServiceStack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LogMessage | |
{ | |
// This property moved to be overriden in derived classes | |
protected string _time = DateTime.UtcNow.ToString("dd/MM/yyyy HH:mm:ss.fff"); | |
public LogLevel Level { get; protected set; } | |
} | |
public class InfoLogMessage : LogMessage | |
{ | |
public InfoLogMessage() | |
{ | |
Level = LogLevel.Info; | |
} | |
// This property is moved out from base class | |
// to make sure it's order to be first in the serialized Json | |
public string Time { get { return _time; } } | |
public object Message { get; set; } | |
public List<string> Tags { get; set; } | |
public override string ToString() | |
{ | |
return this.ToJson(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment