Skip to content
Merged
Changes from all commits
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
27 changes: 16 additions & 11 deletions JSONAPI/Json/JsonApiFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,32 @@ namespace JSONAPI.Json
public class JsonApiFormatter : JsonMediaTypeFormatter
{
public JsonApiFormatter()
: this(new ErrorSerializer())
: this(new ModelManager(), new ErrorSerializer())
{
if (_modelManager == null) _modelManager = new ModelManager();
SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/vnd.api+json"));
}

// Currently for tests only.
internal JsonApiFormatter(IErrorSerializer errorSerializer)
public JsonApiFormatter(IModelManager modelManager) :
this(modelManager, new ErrorSerializer())
{
_modelManager = new ModelManager(new PluralizationService());
_errorSerializer = errorSerializer;
}

public JsonApiFormatter(IModelManager modelManager) : this()
public JsonApiFormatter(IPluralizationService pluralizationService) :
this(new ModelManager(pluralizationService))
{
_modelManager = modelManager;
}

public JsonApiFormatter(IPluralizationService pluralizationService) : this()
// Currently for tests only.
internal JsonApiFormatter(IErrorSerializer errorSerializer)
: this(new ModelManager(), errorSerializer)
{

}

internal JsonApiFormatter(IModelManager modelManager, IErrorSerializer errorSerializer)
{
_modelManager = new ModelManager(pluralizationService);
_modelManager = modelManager;
_errorSerializer = errorSerializer;
SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/vnd.api+json"));
}

[Obsolete]
Expand Down