File tree 5 files changed +23
-18
lines changed
abstractions/src/serialization
5 files changed +23
-18
lines changed Original file line number Diff line number Diff line change @@ -56,12 +56,22 @@ export class ParseNodeFactoryRegistry implements ParseNodeFactory {
56
56
* @param type the class of the factory to be registered.
57
57
* @param backingStoreFactory The backing store factory to use.
58
58
*/
59
- public registerDefaultDeserializer ( type : new ( backingStoreFactory : BackingStoreFactory ) => ParseNodeFactory , backingStoreFactory : BackingStoreFactory ) : void {
59
+ public registerDefaultDeserializerWithBackingStoreFactory ( type : new ( backingStoreFactory : BackingStoreFactory ) => ParseNodeFactory , backingStoreFactory : BackingStoreFactory ) : void {
60
60
if ( ! type ) throw new Error ( "Type is required" ) ;
61
61
const deserializer = new type ( backingStoreFactory ) ;
62
62
this . contentTypeAssociatedFactories . set ( deserializer . getValidContentType ( ) , deserializer ) ;
63
63
}
64
64
65
+ /**
66
+ * Registers the default deserializer to the registry.
67
+ * @param type the class of the factory to be registered.
68
+ */
69
+ public registerDefaultDeserializer ( type : new ( ) => ParseNodeFactory ) : void {
70
+ if ( ! type ) throw new Error ( "Type is required" ) ;
71
+ const deserializer = new type ( ) ;
72
+ this . contentTypeAssociatedFactories . set ( deserializer . getValidContentType ( ) , deserializer ) ;
73
+ }
74
+
65
75
/**
66
76
* Deserializes a buffer into a parsable object
67
77
* @param bufferOrString the value to serialize
Original file line number Diff line number Diff line change @@ -49,8 +49,8 @@ export class DefaultRequestAdapter extends FetchRequestAdapter {
49
49
serializationWriterFactoryRegistry . registerDefaultSerializer ( TextSerializationWriterFactory ) ;
50
50
serializationWriterFactoryRegistry . registerDefaultSerializer ( FormSerializationWriterFactory ) ;
51
51
serializationWriterFactoryRegistry . registerDefaultSerializer ( MultipartSerializationWriterFactory ) ;
52
- parseNodeFactoryRegistry . registerDefaultDeserializer ( JsonParseNodeFactory , backingStoreFactory ) ;
53
- parseNodeFactoryRegistry . registerDefaultDeserializer ( TextParseNodeFactory , backingStoreFactory ) ;
54
- parseNodeFactoryRegistry . registerDefaultDeserializer ( FormParseNodeFactory , backingStoreFactory ) ;
52
+ parseNodeFactoryRegistry . registerDefaultDeserializer ( TextParseNodeFactory ) ;
53
+ parseNodeFactoryRegistry . registerDefaultDeserializerWithBackingStoreFactory ( JsonParseNodeFactory , backingStoreFactory ) ;
54
+ parseNodeFactoryRegistry . registerDefaultDeserializerWithBackingStoreFactory ( FormParseNodeFactory , backingStoreFactory ) ;
55
55
}
56
56
}
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ export class JsonParseNodeFactory implements ParseNodeFactory {
14
14
* Creates an instance of JsonParseNode.
15
15
* @param backingStoreFactory - The factory to create backing stores.
16
16
*/
17
- constructor ( private readonly backingStoreFactory : BackingStoreFactory ) { }
17
+ constructor ( private readonly backingStoreFactory ? : BackingStoreFactory ) { }
18
18
19
19
public getValidContentType ( ) : string {
20
20
return "application/json" ;
Original file line number Diff line number Diff line change 5
5
* -------------------------------------------------------------------------------------------
6
6
*/
7
7
8
- import { BackingStoreFactory , type ParseNode , type ParseNodeFactory } from "@microsoft/kiota-abstractions" ;
8
+ import { type ParseNode , type ParseNodeFactory } from "@microsoft/kiota-abstractions" ;
9
9
10
10
import { TextParseNode } from "./textParseNode" ;
11
11
12
12
export class TextParseNodeFactory implements ParseNodeFactory {
13
- /**
14
- * Creates an instance of TextParseNode.
15
- * @param backingStoreFactory - The factory to create backing stores.
16
- */
17
- constructor ( private readonly backingStoreFactory ?: BackingStoreFactory ) { }
18
13
public getValidContentType ( ) : string {
19
14
return "text/plain" ;
20
15
}
Original file line number Diff line number Diff line change @@ -47,13 +47,13 @@ export function createApiClient(requestAdapter: RequestAdapter) {
47
47
}
48
48
49
49
const backingStoreFactory = requestAdapter . getBackingStoreFactory ( ) ;
50
- serializationWriterFactory . registerDefaultSerializer ( JsonSerializationWriterFactory ) ;
51
- serializationWriterFactory . registerDefaultSerializer ( TextSerializationWriterFactory ) ;
52
- serializationWriterFactory . registerDefaultSerializer ( FormSerializationWriterFactory ) ;
53
- serializationWriterFactory . registerDefaultSerializer ( MultipartSerializationWriterFactory ) ;
54
- parseNodeFactoryRegistry . registerDefaultDeserializer ( JsonParseNodeFactory , backingStoreFactory ) ;
55
- parseNodeFactoryRegistry . registerDefaultDeserializer ( TextParseNodeFactory , backingStoreFactory ) ;
56
- parseNodeFactoryRegistry . registerDefaultDeserializer ( FormParseNodeFactory , backingStoreFactory ) ;
50
+ serializationWriterFactory . registerDefaultSerializer ( JsonSerializationWriterFactory ) ;
51
+ serializationWriterFactory . registerDefaultSerializer ( TextSerializationWriterFactory ) ;
52
+ serializationWriterFactory . registerDefaultSerializer ( FormSerializationWriterFactory ) ;
53
+ serializationWriterFactory . registerDefaultSerializer ( MultipartSerializationWriterFactory ) ;
54
+ parseNodeFactoryRegistry . registerDefaultDeserializer ( TextParseNodeFactory ) ;
55
+ parseNodeFactoryRegistry . registerDefaultDeserializerWithBackingStoreFactory ( JsonParseNodeFactory , backingStoreFactory ) ;
56
+ parseNodeFactoryRegistry . registerDefaultDeserializerWithBackingStoreFactory ( FormParseNodeFactory , backingStoreFactory ) ;
57
57
if ( requestAdapter . baseUrl === undefined || requestAdapter . baseUrl === "" ) {
58
58
requestAdapter . baseUrl = "https://graph.microsoft.com/v1.0" ;
59
59
}
You can’t perform that action at this time.
0 commit comments