Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Serialization

Stanislav Molchanovskiy edited this page Nov 15, 2021 · 1 revision

Serialization is needed to convert data when sending requests and receiving responses. By default, System.Text.Json is used for serialization. But you can replace it with other options:

IMyClient myClient = NClientGallery.Clients.GetCustom()
    .For<IMyClient>(host: "http://localhost:8080")
    .WithSystemJsonSerialization()     // It is already in use, so it is not necessary to call this method
    // or
    .WithJsonSerialization()           // This is the alias for WithJsonSerialization
    // or
    .WithNewtonsoftJsonSerialization()
    // or
    .WithSystemXmlSerialization()
    ...
    .Build();

You can also create your own implementation of the ISerializerProvider and pass it to the WithCustomSerializer method:

ISerializerProvider serializerProvider = ...;

IMyClient myClient = NClientGallery.Clients.GetRest()
    .For<IMyClient>(host: "http://localhost:8080")
    .WithCustomSerialization(serializerProvider)
    .Build();

Clone this wiki locally

Morty Proxy This is a proxified and sanitized view of the page, visit original site.