From 73a5d90c6bbc78e4af49a14b28b5bf3c3bb2fc04 Mon Sep 17 00:00:00 2001 From: Chris Santero Date: Wed, 28 Jan 2015 11:53:01 -0500 Subject: [PATCH] rearrange constructors --- JSONAPI/Json/JsonApiFormatter.cs | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) 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]