UNPKG

@microsoft.azure/autorest.incubator

Version:
53 lines 2.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const property_1 = require("../../../csharp/code-dom/property"); const tweak_model_1 = require("../../../remodeler/tweak-model"); const access_modifier_1 = require("../../../csharp/code-dom/access-modifier"); class ModelProperty extends property_1.BackedProperty { /** emits an expression to deserialize a property from a member inside a container */ deserializeFromContainerMember(mediaType, container, serializedName) { return this.typeDeclaration.deserializeFromContainerMember(mediaType, container, serializedName, this); } /** emits an expression to deserialze a container as the value itself. */ deserializeFromNode(mediaType, node) { return this.typeDeclaration.deserializeFromNode(mediaType, node, this); } /** emits an expression serialize this to the value required by the container */ serializeToNode(mediaType, serializedName) { return this.typeDeclaration.serializeToNode(mediaType, this, serializedName); } /** emits an expression serialize this to a HttpContent */ serializeToContent(mediaType) { return this.typeDeclaration.serializeToContent(mediaType, this); } /** emits the code required to serialize this into a container */ serializeToContainerMember(mediaType, container, serializedName) { return this.typeDeclaration.serializeToContainerMember(mediaType, container, this, serializedName); } constructor(parent, property, serializedName, state, objectInitializer) { const decl = state.project.modelsNamespace.resolveTypeDeclaration(property.schema, property.details.csharp.required, state.path("schema")); super(property.details.csharp.name, decl); this.typeDeclaration = decl; this.serializedName = serializedName; this.schema = property.schema; if (this.schema.readOnly) { this.setAccess = access_modifier_1.Access.Internal; } this.apply(objectInitializer); this.description = property.details.csharp.description; this.externalDocs = property.schema.externalDocs; this.required = property.details.csharp.required; this.IsHeaderProperty = property.details.csharp[tweak_model_1.HeaderProperty] === tweak_model_1.HeaderPropertyType.HeaderAndBody || property.details.csharp[tweak_model_1.HeaderProperty] === tweak_model_1.HeaderPropertyType.Header; } get validatePresenceStatement() { if (this.required) { return this.type.validatePresence(this); } return ``; } get validationStatement() { return this.type.validateValue(this); } } exports.ModelProperty = ModelProperty; //# sourceMappingURL=property.js.map