@microsoft.azure/autorest.incubator
Version:
AutoRest incubator project
32 lines • 2.07 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const class_1 = require("../../../csharp/code-dom/class");
const method_1 = require("../operation/method");
const dictionary_1 = require("../../../common/dictionary");
class ApiClass extends class_1.Class {
// protected sender: Property;
constructor(namespace, state, objectInitializer) {
super(namespace, state.model.details.csharp.name);
this.state = state;
this.apply(objectInitializer);
this.addGeneratedCodeAttribute = true;
// add basics
// this.sender = this.add(new Property("Sender", ClientRuntime.ISendAsync));
// add operations from code model
for (const { key: operationName, value: operation } of dictionary_1.items(state.model.http.operations)) {
// an operation has parameters for parameters, body, callbacks, listener and sender
// we need to make sure that the parameters for a given operation are consistent between the operation method, the call method, and the validation method.
// can we generate the common parameters here and just give them to the methods? (ie, can we share the instances between the methods?)
// code-dom doesn't store references from the child to the parent, so as long as the definitions work without modification, it looks like we can.
// we'll do that work in the OM and expose them as public properties.
const operationMethod = new method_1.OperationMethod(this, operation, state.path('components', 'operations', operationName));
this.addMethod(operationMethod);
this.addMethod(new method_1.CallMethod(this, operationMethod, state.path('components', 'operations', operationName)));
if (!this.state.project.storagePipeline) {
this.addMethod(new method_1.ValidationMethod(this, operationMethod, state.path('components', 'operations', operationName)));
}
}
}
}
exports.ApiClass = ApiClass;
//# sourceMappingURL=api-class.js.map