Skip to content

Commit 60407b7

Browse files
committed
Migrate static functions to instance methods
1 parent 8dd1703 commit 60407b7

File tree

10 files changed

+353
-344
lines changed

10 files changed

+353
-344
lines changed

packages/abstractions/src/apiClientBuilder.ts

+5-64
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,9 @@
44
* See License in the project root for license information.
55
* -------------------------------------------------------------------------------------------
66
*/
7-
import { type ParseNodeFactory, ParseNodeFactoryRegistry, type SerializationWriterFactory, SerializationWriterFactoryRegistry } from "./serialization";
8-
import { BackingStoreParseNodeFactory, BackingStoreSerializationWriterProxyFactory } from "./store";
7+
import { ParseNodeFactoryRegistry, type SerializationWriterFactory, SerializationWriterFactoryRegistry } from "./serialization";
8+
import { BackingStoreSerializationWriterProxyFactory } from "./store";
99

10-
/**
11-
* Registers the default serializer to the registry.
12-
* @param serializationWriterFactoryRegistry The registry to which the default serializer will be registered.
13-
* @param type the class of the factory to be registered.
14-
*/
15-
export function registerDefaultSerializer(serializationWriterFactoryRegistry: SerializationWriterFactoryRegistry, type: new () => SerializationWriterFactory): void {
16-
if (!type) throw new Error("Type is required");
17-
const serializer = new type();
18-
serializationWriterFactoryRegistry.contentTypeAssociatedFactories.set(serializer.getValidContentType(), serializer);
19-
}
20-
/**
21-
* Registers the default deserializer to the registry.
22-
* @param parseNodeFactoryRegistry The registry to which the default deserializer will be registered.
23-
* @param type the class of the factory to be registered.
24-
*/
25-
export function registerDefaultDeserializer(parseNodeFactoryRegistry: ParseNodeFactoryRegistry, type: new () => ParseNodeFactory): void {
26-
if (!type) throw new Error("Type is required");
27-
const deserializer = new type();
28-
parseNodeFactoryRegistry.contentTypeAssociatedFactories.set(deserializer.getValidContentType(), deserializer);
29-
}
3010
/**
3111
* Enables the backing store on default serialization writers and the given serialization writer.
3212
* @param serializationWriterFactoryRegistry The serialization writer factory registry to enable the backing store on.
@@ -38,50 +18,11 @@ export function enableBackingStoreForSerializationWriterFactory(serializationWri
3818
if (!original) throw new Error("Original must be specified");
3919
let result = original;
4020
if (original instanceof SerializationWriterFactoryRegistry) {
41-
enableBackingStoreForSerializationRegistry(original);
21+
original.enableBackingStoreForSerializationRegistry();
4222
} else {
4323
result = new BackingStoreSerializationWriterProxyFactory(original);
4424
}
45-
enableBackingStoreForSerializationRegistry(serializationWriterFactoryRegistry);
46-
enableBackingStoreForParseNodeRegistry(parseNodeFactoryRegistry);
25+
serializationWriterFactoryRegistry.enableBackingStoreForSerializationRegistry();
26+
parseNodeFactoryRegistry.enableBackingStoreForParseNodeRegistry();
4727
return result;
4828
}
49-
/**
50-
* Enables the backing store on default parse node factories and the given parse node factory.
51-
* @param parseNodeFactoryRegistry The parse node factory registry to enable the backing store on.
52-
* @param original The parse node factory to enable the backing store on.
53-
* @returns A new parse node factory with the backing store enabled.
54-
*/
55-
export function enableBackingStoreForParseNodeFactory(parseNodeFactoryRegistry: ParseNodeFactoryRegistry, original: ParseNodeFactory): ParseNodeFactory {
56-
if (!original) throw new Error("Original must be specified");
57-
let result = original;
58-
if (original instanceof ParseNodeFactoryRegistry) {
59-
enableBackingStoreForParseNodeRegistry(original);
60-
} else {
61-
result = new BackingStoreParseNodeFactory(original);
62-
}
63-
enableBackingStoreForParseNodeRegistry(parseNodeFactoryRegistry);
64-
return result;
65-
}
66-
/**
67-
* Enables the backing store on the given parse node factory registry.
68-
* @param registry The parse node factory registry to enable the backing store on.
69-
*/
70-
function enableBackingStoreForParseNodeRegistry(registry: ParseNodeFactoryRegistry): void {
71-
for (const [k, v] of registry.contentTypeAssociatedFactories) {
72-
if (!(v instanceof BackingStoreParseNodeFactory || v instanceof ParseNodeFactoryRegistry)) {
73-
registry.contentTypeAssociatedFactories.set(k, new BackingStoreParseNodeFactory(v));
74-
}
75-
}
76-
}
77-
/**
78-
* Enables the backing store on the given serialization factory registry.
79-
* @param registry The serialization factory registry to enable the backing store on.
80-
*/
81-
function enableBackingStoreForSerializationRegistry(registry: SerializationWriterFactoryRegistry): void {
82-
for (const [k, v] of registry.contentTypeAssociatedFactories) {
83-
if (!(v instanceof BackingStoreSerializationWriterProxyFactory || v instanceof SerializationWriterFactoryRegistry)) {
84-
registry.contentTypeAssociatedFactories.set(k, new BackingStoreSerializationWriterProxyFactory(v));
85-
}
86-
}
87-
}

packages/abstractions/src/serialization/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
* -------------------------------------------------------------------------------------------
66
*/
77
export * from "./additionalDataHolder";
8-
export * from "./kiotaJsonSerializer";
9-
export * from "./kiotaSerializer";
108
export * from "./parsable";
119
export * from "./parsableFactory";
1210
export * from "./parseNode";

packages/abstractions/src/serialization/kiotaJsonSerializer.ts

-79
This file was deleted.

packages/abstractions/src/serialization/kiotaSerializer.ts

-157
This file was deleted.

0 commit comments

Comments
 (0)