@microsoft/kiota-abstractions
Version:
Core abstractions for kiota generated libraries in TypeScript and JavaScript
37 lines • 2.04 kB
JavaScript
/**
* -------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
* See License in the project root for license information.
* -------------------------------------------------------------------------------------------
*/
import { SerializationWriterProxyFactory } from "../serialization/index.js";
/** Proxy implementation of SerializationWriterFactory for the backing store that automatically sets the state of the backing store when serializing. */
export class BackingStoreSerializationWriterProxyFactory extends SerializationWriterProxyFactory {
/**
* Initializes a new instance of the BackingStoreSerializationWriterProxyFactory class given a concrete implementation of SerializationWriterFactory.
* @param concrete a concrete implementation of SerializationWriterFactory to wrap.
*/
constructor(concrete) {
super(concrete, (value) => {
const backedModel = value;
if (backedModel === null || backedModel === void 0 ? void 0 : backedModel.backingStore) {
backedModel.backingStore.returnOnlyChangedValues = true;
}
}, (value) => {
const backedModel = value;
if (backedModel === null || backedModel === void 0 ? void 0 : backedModel.backingStore) {
backedModel.backingStore.returnOnlyChangedValues = false;
backedModel.backingStore.initializationCompleted = true;
}
}, (value, writer) => {
const backedModel = value;
if (backedModel === null || backedModel === void 0 ? void 0 : backedModel.backingStore) {
const keys = backedModel.backingStore.enumerateKeysForValuesChangedToNull();
for (const key of keys) {
writer.writeNullValue(key);
}
}
});
}
}
//# sourceMappingURL=backingStoreSerializationWriterProxyFactory.js.map