@yellicode/elements
Version:
The meta model API for Yellicode - an extensible code generator.
33 lines (32 loc) • 1.36 kB
JavaScript
import { ModelDelegateImpl } from './model-delegate';
import { ElementMapImpl } from './element-map';
import * as elements from './interfaces';
import { Document } from './document';
var ModelFactory = /** @class */ (function () {
function ModelFactory() {
}
/**
* Creates a new model with the specified name. Use the initFn callback to add
* other elements to the model.
*/
ModelFactory.create = function (name, initFn, customTypeResolver) {
var elementMap = new ElementMapImpl(customTypeResolver);
var modelDelegate = new ModelDelegateImpl(elementMap);
var properties = { name: name };
var model = modelDelegate.createElement('model', null, properties, initFn);
return model;
};
ModelFactory.createDocument = function (creator, initFn, customTypeResolver) {
var elementMap = new ElementMapImpl(customTypeResolver);
var modelDelegate = new ModelDelegateImpl(elementMap);
var properties = { creator: creator };
var document = Document.create(modelDelegate, properties);
document.modelTypeName = 'Yellicode YML';
document.modelTypeVersion = elements.MetaVersion;
if (initFn)
initFn(document);
return document;
};
return ModelFactory;
}());
export { ModelFactory };