UNPKG

@microsoft.azure/autorest.incubator

Version:
125 lines 6.58 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const dotnet = require("../../../csharp/code-dom/mscorlib"); const parameter_1 = require("../../../csharp/code-dom/parameter"); const media_types_1 = require("../../../common/media-types"); /** represents a method parameter for an http operation (header/cookie/query/path) */ class OperationParameter extends parameter_1.Parameter { constructor(parent, param, state, objectInitializer) { const typeDeclaration = state.project.modelsNamespace.resolveTypeDeclaration(param.schema, param.required, state.path('schema')); super(param.details.csharp.name, typeDeclaration); this.param = param; this.typeDeclaration = typeDeclaration; this.apply(objectInitializer); this.description = param.details.csharp.description || ''; } /** emits an expression to deserialize a property from a member inside a container */ deserializeFromContainerMember(mediaType, container, serializedName) { // return this.assign(this.typeDeclaration.deserializeFromContainerMember(mediaType, container, serializedName, this)) 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, this, container, serializedName); } get validatePresenceStatement() { return this.typeDeclaration.validatePresence(this); } get validationStatement() { return this.typeDeclaration.validateValue(this); } } exports.OperationParameter = OperationParameter; /** represents a method parameter for an http operation (body) */ class OperationBodyParameter extends parameter_1.Parameter { /** emits an expression to deserialize a property from a member inside a container */ deserializeFromContainerMember(mediaType, container, serializedName) { //return this.assign(this.typeDeclaration.deserializeFromContainerMember(mediaType, container, serializedName, this)); return this.typeDeclaration.deserializeFromContainerMember(mediaType, container, serializedName, this); } /** emits an expression to deserialze a container as the value itself. */ deserializeFromNode(mediaType, node) { // return this.assign(this.typeDeclaration.deserializeFromNode(mediaType, node, this)); 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, this, container, serializedName); } get validatePresenceStatement() { return this.typeDeclaration.validatePresence(this); } get validationStatement() { return this.typeDeclaration.validateValue(this); } constructor(parent, name, description, schema, required, state, objectInitializer) { const typeDeclaration = state.project.modelsNamespace.resolveTypeDeclaration(schema, required, state.path('schema')); super(name, typeDeclaration); this.typeDeclaration = typeDeclaration; this.mediaType = media_types_1.KnownMediaType.Json; this.apply(objectInitializer); this.description = description || schema.details.csharp.description; } get jsonSerializationStatement() { // get the body serialization from the typeDeclaration. return '/* body parameter */'; // (<TypeDeclaration>this.type).jsonserialize(this.name); } get jsonDeserializationStatement() { return '/* body parameter */'; // (<TypeDeclaration>this.type).jsonDeserializationImplementation(this.name); } } exports.OperationBodyParameter = OperationBodyParameter; class CallbackParameter extends parameter_1.Parameter { constructor(name, responseType, headerType, state, objectInitializer) { if (state.project.storagePipeline) { if (responseType && responseType.declaration !== 'System.IO.Stream') { if (headerType) { super(name, dotnet.System.Action(dotnet.System.Net.Http.HttpResponseMessage, responseType, headerType)); } else { super(name, dotnet.System.Action(dotnet.System.Net.Http.HttpResponseMessage, responseType)); } } else { if (headerType) { super(name, dotnet.System.Action(dotnet.System.Net.Http.HttpResponseMessage, headerType)); } else { super(name, dotnet.System.Action(dotnet.System.Net.Http.HttpResponseMessage)); } } } else { if (responseType) { super(name, dotnet.System.Func(dotnet.System.Net.Http.HttpRequestMessage, dotnet.System.Net.Http.HttpResponseMessage, responseType, dotnet.System.Threading.Tasks.Task())); } else { super(name, dotnet.System.Func(dotnet.System.Net.Http.HttpRequestMessage, dotnet.System.Net.Http.HttpResponseMessage, dotnet.System.Threading.Tasks.Task())); } } this.responseType = responseType; this.headerType = headerType; } } exports.CallbackParameter = CallbackParameter; //# sourceMappingURL=parameter.js.map