Skip to content

Instantly share code, notes, and snippets.

@elutsky
Last active August 29, 2015 14:00
Show Gist options
  • Save elutsky/11361196 to your computer and use it in GitHub Desktop.
Save elutsky/11361196 to your computer and use it in GitHub Desktop.
ToJson() extension method serialization order with ServiceStack
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