diff --git a/JSONAPI/Json/JsonApiFormatter.cs b/JSONAPI/Json/JsonApiFormatter.cs index 47ae724b..a80fbbcc 100644 --- a/JSONAPI/Json/JsonApiFormatter.cs +++ b/JSONAPI/Json/JsonApiFormatter.cs @@ -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]