in powershell/llcsharp/model/interface.ts [204:289]
init() {
(<any>this).init = () => { }; // only allow a single init!
this.schema.language.csharp = this.schema.language.csharp || new Language();
const implData = (this.schema.language.csharp = this.schema.language.csharp || {});
//implData.interfaceImplementation = this;
this.description = `${this.schema.language.csharp.description}`;
const virtualProperties: NewVirtualProperties = this.schema.language.csharp.virtualProperties || {
owned: [],
inherited: [],
inlined: []
};
if (this.schema.language.csharp.virtualProperties) {
for (const virtualProperty of values(virtualProperties.owned)) {
if (virtualProperty.private && !this.isInternal) {
continue;
}
const modelProperty = virtualProperty.property;
const internalSet = !!(!this.isInternal && (modelProperty.readOnly || !!virtualProperty.readOnly || (<any>modelProperty.language.csharp).constantValue));
const isRequired = !!(virtualProperty.required && virtualProperty.read && virtualProperty.create && virtualProperty.update);
const mutability = { read: !!virtualProperty.read, update: !!virtualProperty.update, create: !!virtualProperty.create };
const pType = this.state.project.modelsNamespace.NewResolveTypeDeclaration(<NewSchema>modelProperty.schema, isRequired, this.state.path('schema'));
const p = this.add(new InterfaceProperty(virtualProperty.name, pType, {
description: modelProperty.language.default.description,
setAccess: internalSet ? Access.Internal : Access.Public
}));
this.addInfoAttribute(p, pType, isRequired, internalSet, mutability, modelProperty.language.default.description, modelProperty.serializedName);
if (isEnumImplementation(modelProperty.schema)) {
addPSArgumentCompleterAttribute(p, modelProperty.schema);
} else if (pType instanceof ArrayOf && isEnumImplementation((<any>modelProperty.schema).elementType)) {
addPSArgumentCompleterAttribute(p, (<any>modelProperty.schema).elementType);
}
if (!this.isInternal && (<any>modelProperty.language.csharp).constantValue !== undefined) {
p.setAccess = Access.Internal;
}
}
for (const virtualProperty of values(virtualProperties.inlined)) {
// don't publicly expose the 'private' properties.
if (virtualProperty.private && !this.isInternal) {
continue;
}
const modelProperty = virtualProperty.property;
const isRequired = !!(virtualProperty.required && virtualProperty.read && virtualProperty.create && virtualProperty.update);
const mutability = { read: !!virtualProperty.read, update: !!virtualProperty.update, create: !!virtualProperty.create };
const pType = this.state.project.modelsNamespace.NewResolveTypeDeclaration(<NewSchema>modelProperty.schema, isRequired, this.state.path('schema'));
const internalSet = !!(!this.isInternal && (modelProperty.readOnly || !!virtualProperty.readOnly || (<any>modelProperty.language.csharp).constantValue));
const p = this.add(new InterfaceProperty(virtualProperty.name, pType, {
description: modelProperty.language.default.description,
setAccess: internalSet ? Access.Internal : Access.Public
}));
this.addInfoAttribute(p, pType, isRequired, internalSet, mutability, modelProperty.language.default.description, modelProperty.serializedName);
if (isEnumImplementation(modelProperty.schema)) {
addPSArgumentCompleterAttribute(p, modelProperty.schema);
} else if (pType instanceof ArrayOf && isEnumImplementation((<any>modelProperty.schema).elementType)) {
addPSArgumentCompleterAttribute(p, (<any>modelProperty.schema).elementType);
}
}
}
if (!this.isInternal) {
// mark it as json serializable
if (!this.schema.language.csharp.isHeaderModel) {
if (this.state.project.jsonSerialization) {
this.interfaces.push(ClientRuntime.IJsonSerializable);
}
if (this.state.project.xmlSerialization) {
this.interfaces.push(ClientRuntime.IXmlSerializable);
}
}
}
return this;
}