Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
ServiceStack/src/ServiceStack.Client/JsonServiceClient.cs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
36 lines (27 sloc)
1.15 KB
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
using System.IO; | |
using ServiceStack.Serialization; | |
using ServiceStack.Text; | |
using ServiceStack.Web; | |
namespace ServiceStack | |
{ | |
public class JsonServiceClient | |
: ServiceClientBase, IJsonServiceClient | |
{ | |
public override string Format => "json"; | |
public JsonServiceClient() {} | |
public JsonServiceClient(string baseUri) | |
{ | |
SetBaseUri(baseUri); | |
} | |
public JsonServiceClient(string syncReplyBaseUri, string asyncOneWayBaseUri) | |
: base(syncReplyBaseUri, asyncOneWayBaseUri) {} | |
public override string ContentType => $"application/{Format}"; | |
public override void SerializeToStream(IRequest req, object request, Stream stream) => | |
JsonDataContractSerializer.Instance.SerializeToStream(request, stream); | |
public override T DeserializeFromStream<T>(Stream stream) => | |
JsonDataContractSerializer.Instance.DeserializeFromStream<T>(stream); | |
public override StreamDeserializerDelegate StreamDeserializer => JsonSerializer.DeserializeFromStream; | |
internal static JsonObject ParseObject(string json) => | |
JsonObject.Parse(json); | |
} | |
} |