@microsoft.azure/autorest.incubator
Version:
AutoRest incubator project
43 lines • 1.9 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const text_manipulation_1 = require("../../common/text-manipulation");
const type_1 = require("./type");
class Interface extends type_1.Type {
constructor(parent, name, objectIntializer) {
super(parent, name);
this.addGeneratedCodeAttribute = false;
this.apply(objectIntializer);
parent.addInterface(this);
}
get fileName() {
return this.name;
}
get codeGenAttribute() {
return this.addGeneratedCodeAttribute ? '\n[System.CodeDom.Compiler.GeneratedCode("AutoRest/Incubator", "1.1")]' : '';
}
get definition() {
const colon = this.interfaces.length > 0 ? ' : ' : '';
const implementsInterfaces = this.interfaces.map(v => v.fullName).join(', ');
const description = text_manipulation_1.comment(this.description, text_manipulation_1.docCommentPrefix);
const methods = this.methods.sort(text_manipulation_1.sortByName).map(m => m.interfaceDeclaration).join(text_manipulation_1.EOL);
let properties = this.properties.sort(text_manipulation_1.sortByName).map(m => m.declaration).join(text_manipulation_1.EOL);
const partial = this.partial ? 'partial ' : '';
if (properties.indexOf('[]') > -1) {
properties = `#pragma warning disable CA1819 // Properties should not return arrays
${properties}
#pragma warning restore CA1819 // Properties should not return arrays`;
}
return `
${description}${this.codeGenAttribute}
${this.attributeDeclaration}${this.accessModifier} ${partial}interface ${this.name}${colon}${implementsInterfaces} {
${text_manipulation_1.indent(properties, 1)}
${text_manipulation_1.indent(methods, 1)}
}
`.trim();
}
get declaration() {
return this.fullName;
}
}
exports.Interface = Interface;
//# sourceMappingURL=interface.js.map