@microsoft.azure/autorest.incubator
Version:
AutoRest incubator project
70 lines • 3.23 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const dictionary_1 = require("../../../common/dictionary");
const interface_1 = require("../../../csharp/code-dom/interface");
const clientruntime_1 = require("../../../csharp/lowlevel-generator/clientruntime");
const interface_property_1 = require("./interface-property");
class ModelInterface extends interface_1.Interface {
constructor(parent, schema, implementation, state, objectInitializer) {
super(parent, `I${schema.details.csharp.name}`);
this.implementation = implementation;
this.state = state;
this.partial = true;
this.apply(objectInitializer);
const implData = (schema.details.csharp = schema.details.csharp || {});
implData.interfaceImplementation = this;
this.addGeneratedCodeAttribute = true;
for (const { key: propertyName, value: property } of dictionary_1.items(schema.properties)) {
this.add(new interface_property_1.ModelInterfaceProperty(this, property, state.path('properties', propertyName)));
}
// mark it as json serializable
if (!schema.details.default.isHeaderModel) {
if (this.state.project.jsonSerialization) {
this.interfaces.push(clientruntime_1.ClientRuntime.IJsonSerializable);
}
if (this.state.project.xmlSerialization) {
this.interfaces.push(clientruntime_1.ClientRuntime.IXmlSerializable);
}
}
}
get schema() {
return this.implementation.schema;
}
deserializeFromContainerMember(mediaType, container, serializedName, defaultValue) {
return this.implementation.deserializeFromContainerMember(mediaType, container, serializedName, defaultValue);
}
deserializeFromNode(mediaType, node, defaultValue) {
return this.implementation.deserializeFromNode(mediaType, node, defaultValue);
}
/** emits an expression to deserialize content from a string */
deserializeFromString(mediaType, content, defaultValue) {
return this.implementation.deserializeFromString(mediaType, content, defaultValue);
}
/** emits an expression serialize this to a HttpContent */
serializeToContent(mediaType, value) {
return this.implementation.serializeToContent(mediaType, value);
}
serializeToNode(mediaType, value, serializedName) {
return this.implementation.serializeToNode(mediaType, value, serializedName);
}
serializeToContainerMember(mediaType, value, container, serializedName) {
return this.implementation.serializeToContainerMember(mediaType, value, container, serializedName);
}
get isXmlAttribute() {
return this.implementation.isXmlAttribute;
}
get isRequired() {
return this.implementation.isRequired;
}
validatePresence(property) {
return this.implementation.validatePresence(property);
}
validateValue(property) {
return this.implementation.validateValue(property);
}
get hasHeaderProperties() {
return this.implementation.hasHeaderProperties;
}
}
exports.ModelInterface = ModelInterface;
//# sourceMappingURL=interface.js.map