Skip to content

Commit 07a1639

Browse files
committed
Merge pull request #33 from csantero/rearrange-constructors
rearrange constructors
2 parents dac651b + 73a5d90 commit 07a1639

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

JSONAPI/Json/JsonApiFormatter.cs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,32 @@ namespace JSONAPI.Json
2020
public class JsonApiFormatter : JsonMediaTypeFormatter
2121
{
2222
public JsonApiFormatter()
23-
: this(new ErrorSerializer())
23+
: this(new ModelManager(), new ErrorSerializer())
2424
{
25-
if (_modelManager == null) _modelManager = new ModelManager();
26-
SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/vnd.api+json"));
2725
}
2826

29-
// Currently for tests only.
30-
internal JsonApiFormatter(IErrorSerializer errorSerializer)
27+
public JsonApiFormatter(IModelManager modelManager) :
28+
this(modelManager, new ErrorSerializer())
3129
{
32-
_modelManager = new ModelManager(new PluralizationService());
33-
_errorSerializer = errorSerializer;
3430
}
3531

36-
public JsonApiFormatter(IModelManager modelManager) : this()
32+
public JsonApiFormatter(IPluralizationService pluralizationService) :
33+
this(new ModelManager(pluralizationService))
3734
{
38-
_modelManager = modelManager;
3935
}
4036

41-
public JsonApiFormatter(IPluralizationService pluralizationService) : this()
37+
// Currently for tests only.
38+
internal JsonApiFormatter(IErrorSerializer errorSerializer)
39+
: this(new ModelManager(), errorSerializer)
40+
{
41+
42+
}
43+
44+
internal JsonApiFormatter(IModelManager modelManager, IErrorSerializer errorSerializer)
4245
{
43-
_modelManager = new ModelManager(pluralizationService);
46+
_modelManager = modelManager;
47+
_errorSerializer = errorSerializer;
48+
SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/vnd.api+json"));
4449
}
4550

4651
[Obsolete]

0 commit comments

Comments
 (0)