@@ -10,9 +10,13 @@ import type { Parsable } from "./parsable";
10
10
import type { ModelSerializerFunction } from "./serializationFunctionTypes" ;
11
11
import { BackingStoreSerializationWriterProxyFactory } from "../store" ;
12
12
13
- const jsonContentType = "application/json" ;
14
13
/** This factory holds a list of all the registered factories for the various types of nodes. */
15
14
export class SerializationWriterFactoryRegistry implements SerializationWriterFactory {
15
+ /**
16
+ * The content type for JSON data.
17
+ */
18
+ private readonly jsonContentType = "application/json" ;
19
+
16
20
public getValidContentType ( ) : string {
17
21
throw new Error ( "The registry supports multiple content types. Get the registered factory instead." ) ;
18
22
}
@@ -63,7 +67,7 @@ export class SerializationWriterFactoryRegistry implements SerializationWriterFa
63
67
* @returns a buffer containing the serialized value
64
68
*/
65
69
public serializeToJson < T extends Parsable > ( value : T , serializationFunction : ModelSerializerFunction < T > ) : ArrayBuffer {
66
- return this . serialize ( jsonContentType , value , serializationFunction ) ;
70
+ return this . serialize ( this . jsonContentType , value , serializationFunction ) ;
67
71
}
68
72
69
73
/**
@@ -73,7 +77,7 @@ export class SerializationWriterFactoryRegistry implements SerializationWriterFa
73
77
* @returns a string representing the serialized value
74
78
*/
75
79
public serializeToJsonAsString < T extends Parsable > ( value : T , serializationFunction : ModelSerializerFunction < T > ) : string {
76
- return this . serializeToString ( jsonContentType , value , serializationFunction ) ;
80
+ return this . serializeToString ( this . jsonContentType , value , serializationFunction ) ;
77
81
}
78
82
79
83
/**
@@ -83,7 +87,7 @@ export class SerializationWriterFactoryRegistry implements SerializationWriterFa
83
87
* @returns a string representing the serialized value
84
88
*/
85
89
public serializeCollectionToJson < T extends Parsable > ( values : T [ ] , serializationFunction : ModelSerializerFunction < T > ) : ArrayBuffer {
86
- return this . serializeCollection ( jsonContentType , values , serializationFunction ) ;
90
+ return this . serializeCollection ( this . jsonContentType , values , serializationFunction ) ;
87
91
}
88
92
89
93
/**
@@ -93,7 +97,7 @@ export class SerializationWriterFactoryRegistry implements SerializationWriterFa
93
97
* @returns a string representing the serialized value
94
98
*/
95
99
public serializeCollectionToJsonAsString < T extends Parsable > ( values : T [ ] , serializationFunction : ModelSerializerFunction < T > ) : string {
96
- return this . serializeCollectionToString ( jsonContentType , values , serializationFunction ) ;
100
+ return this . serializeCollectionToString ( this . jsonContentType , values , serializationFunction ) ;
97
101
}
98
102
99
103
/**
0 commit comments