Reputation: 2729
I use ServiceStack.Text with ServiceStack (the web service framework).
I'm trying to add a custom serialization route for a specific type in AppHost.Configure()
. However, the settings do not apply/are ignored.
public AppHost : AppHostBase
{
...
public override void Configure(Container container)
{
//Register custom serialization routine
ServiceStack.Text.JsConfig<CultureInfo>.SerializeFn = r => r.TwoLetterISOLanguageName;
ServiceStack.Text.JsConfig<CultureInfo>.DeSerializeFn = r => return new CultureInfo(r);
}
}
Upvotes: 5
Views: 1136
Reputation: 2729
ServiceStack.Text is caching internally very heavily to achieve fast performance. ServiceStack is already starting the cache creation process before AppHost.Configure()
is called.
So to resolve this issue, you need to register your settings before AppHost.Init()
is called.
Of course this isn't required for all settings in ServiceStack.Text - it's only required for the settings which will be cached before AppHost.Configure()
is called.
Upvotes: 7