Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a way to change the objects are serialized CustomJsonSerializerSettings #56

Open
wants to merge 4 commits into
base: next
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
using defaultconverters
  • Loading branch information
jjchiw committed Oct 17, 2016
commit 9055e8835bcd40adae0d30c7e2e4513c15d02ee6
24 changes: 15 additions & 9 deletions src/ArangoDB.Client/Serialization/DocumentSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,7 @@ public JsonSerializerSettings SerializerSetting
{
get
{
var convertes = new List<JsonConverter>
{
new DateTimeConverter(),
new QueryParameterConverter(),
new EnumValueConverter()
}.Concat(db.Setting.Serialization.Converters).ToList();

if (db.Setting.Serialization.SerializeEnumAsInteger == false)
convertes.Add(new StringEnumConverter());
List<JsonConverter> convertes = GetConverters();

return new JsonSerializerSettings
{
Expand All @@ -113,6 +105,20 @@ public JsonSerializerSettings SerializerSetting
}
}

private List<JsonConverter> GetConverters()
{
var convertes = new List<JsonConverter>
{
new DateTimeConverter(),
new QueryParameterConverter(),
new EnumValueConverter()
}.Concat(db.Setting.Serialization.Converters).ToList();

if (db.Setting.Serialization.SerializeEnumAsInteger == false)
convertes.Add(new StringEnumConverter());
return convertes;
}

public JObject FromObject(object document)
{
return JObject.FromObject(document, CreateJsonSerializer());
Expand Down