UNPKG

@autorest/powershell

Version:
38 lines 2.38 kB
"use strict"; /*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ Object.defineProperty(exports, "__esModule", { value: true }); exports.EnumImplementation = void 0; const string_1 = require("./string"); const codegen_csharp_1 = require("@azure-tools/codegen-csharp"); const codemodel_v3_1 = require("@azure-tools/codemodel-v3"); class EnumImplementation extends string_1.String { get isNullable() { return !this.isRequired; } constructor(schema, isRequired) { super(schema, isRequired); this.isXmlAttribute = false; } get defaultOfType() { var _a, _b; return this.isRequired ? (0, codegen_csharp_1.toExpression)(`((${(_a = this.schema.language.csharp) === null || _a === void 0 ? void 0 : _a.namespace}.${(_b = this.schema.language.csharp) === null || _b === void 0 ? void 0 : _b.name}${this.isRequired ? '' : '?'})"")`) : codegen_csharp_1.dotnet.Null; } get convertObjectMethod() { var _a, _b; return `${(_a = this.schema.language.csharp) === null || _a === void 0 ? void 0 : _a.namespace}.${(_b = this.schema.language.csharp) === null || _b === void 0 ? void 0 : _b.name}.CreateFrom`; } get declaration() { var _a, _b; return `${(_a = this.schema.language.csharp) === null || _a === void 0 ? void 0 : _a.namespace}.${(_b = this.schema.language.csharp) === null || _b === void 0 ? void 0 : _b.name}${this.isRequired ? '' : '?'}`; } /** emits an expression to deserialize content from a content/response */ deserializeFromResponse(mediaType, content, defaultValue) { switch (mediaType) { case codemodel_v3_1.KnownMediaType.Json: return (0, codegen_csharp_1.toExpression)(`${content}.Content.ReadAsStringAsync().ContinueWith( body => ${this.deserializeFromString(mediaType, 'body.Result', defaultValue)})`); } return (0, codegen_csharp_1.toExpression)(`null /* deserializeFromResponse doesn't support '${mediaType}' ${__filename}*/`); } } exports.EnumImplementation = EnumImplementation; //# sourceMappingURL=enum.js.map