|
7 | 7 | import { type ParseNodeFactory, ParseNodeFactoryRegistry, type SerializationWriterFactory, SerializationWriterFactoryRegistry } from "./serialization";
|
8 | 8 | import { BackingStoreParseNodeFactory, BackingStoreSerializationWriterProxyFactory } from "./store";
|
9 | 9 |
|
10 |
| -/** |
11 |
| - * Registers the default serializer to the registry. |
12 |
| - * @param type the class of the factory to be registered. |
13 |
| - */ |
14 |
| -export function registerDefaultSerializer(type: new () => SerializationWriterFactory): void { |
15 |
| - if (!type) throw new Error("Type is required"); |
16 |
| - const serializer = new type(); |
17 |
| - SerializationWriterFactoryRegistry.defaultInstance.contentTypeAssociatedFactories.set(serializer.getValidContentType(), serializer); |
18 |
| -} |
19 |
| -/** |
20 |
| - * Registers the default deserializer to the registry. |
21 |
| - * @param type the class of the factory to be registered. |
22 |
| - */ |
23 |
| -export function registerDefaultDeserializer(type: new () => ParseNodeFactory): void { |
24 |
| - if (!type) throw new Error("Type is required"); |
25 |
| - const deserializer = new type(); |
26 |
| - ParseNodeFactoryRegistry.defaultInstance.contentTypeAssociatedFactories.set(deserializer.getValidContentType(), deserializer); |
27 |
| -} |
28 | 10 | /**
|
29 | 11 | * Enables the backing store on default serialization writers and the given serialization writer.
|
| 12 | + * @param serializationWriterFactoryRegistry The serialization writer factory registry to enable the backing store on. |
| 13 | + * @param parseNodeFactoryRegistry The parse node factory registry to enable the backing store on. |
30 | 14 | * @param original The serialization writer to enable the backing store on.
|
31 | 15 | * @returns A new serialization writer with the backing store enabled.
|
32 | 16 | */
|
33 |
| -export function enableBackingStoreForSerializationWriterFactory(original: SerializationWriterFactory): SerializationWriterFactory { |
| 17 | +export function enableBackingStoreForSerializationWriterFactory(serializationWriterFactoryRegistry: SerializationWriterFactoryRegistry, parseNodeFactoryRegistry: ParseNodeFactoryRegistry, original: SerializationWriterFactory): SerializationWriterFactory { |
34 | 18 | if (!original) throw new Error("Original must be specified");
|
35 | 19 | let result = original;
|
36 | 20 | if (original instanceof SerializationWriterFactoryRegistry) {
|
37 | 21 | enableBackingStoreForSerializationRegistry(original);
|
38 | 22 | } else {
|
39 | 23 | result = new BackingStoreSerializationWriterProxyFactory(original);
|
40 | 24 | }
|
41 |
| - enableBackingStoreForSerializationRegistry(SerializationWriterFactoryRegistry.defaultInstance); |
42 |
| - enableBackingStoreForParseNodeRegistry(ParseNodeFactoryRegistry.defaultInstance); |
| 25 | + enableBackingStoreForSerializationRegistry(serializationWriterFactoryRegistry); |
| 26 | + enableBackingStoreForParseNodeRegistry(parseNodeFactoryRegistry); |
43 | 27 | return result;
|
44 | 28 | }
|
45 | 29 | /**
|
46 | 30 | * Enables the backing store on default parse node factories and the given parse node factory.
|
| 31 | + * @param parseNodeFactoryRegistry The parse node factory registry to enable the backing store on. |
47 | 32 | * @param original The parse node factory to enable the backing store on.
|
48 | 33 | * @returns A new parse node factory with the backing store enabled.
|
49 | 34 | */
|
50 |
| -export function enableBackingStoreForParseNodeFactory(original: ParseNodeFactory): ParseNodeFactory { |
| 35 | +export function enableBackingStoreForParseNodeFactory(parseNodeFactoryRegistry: ParseNodeFactoryRegistry, original: ParseNodeFactory): ParseNodeFactory { |
51 | 36 | if (!original) throw new Error("Original must be specified");
|
52 | 37 | let result = original;
|
53 | 38 | if (original instanceof ParseNodeFactoryRegistry) {
|
54 | 39 | enableBackingStoreForParseNodeRegistry(original);
|
55 | 40 | } else {
|
56 | 41 | result = new BackingStoreParseNodeFactory(original);
|
57 | 42 | }
|
58 |
| - enableBackingStoreForParseNodeRegistry(ParseNodeFactoryRegistry.defaultInstance); |
| 43 | + enableBackingStoreForParseNodeRegistry(parseNodeFactoryRegistry); |
59 | 44 | return result;
|
60 | 45 | }
|
61 | 46 | /**
|
|
0 commit comments