UNPKG

woltlab-compiler

Version:

A compiler for WoltLab-Package Archives and WoltLab-Package Components

78 lines 2.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const util_1 = require("util"); const BidirectionalCollection_1 = require("../../Collections/BidirectionalCollection"); const XML_1 = require("../../Serialization/XML"); const XMLEditor_1 = require("../../Serialization/XMLEditor"); /** * Represents a collection of instructions. */ class InstructionSet extends BidirectionalCollection_1.BidirectionalCollection { /** * Initializes a new instance of the `InstructionSet` class. */ constructor($package) { super(null); /** * The directory to save the set to. */ this.directory = "components"; this.Package = $package; } /** * @inheritdoc */ get Owner() { return this; } /** * Gets or sets the package the collection belongs to. */ get Package() { return this.package; } set Package(value) { this.package = value; } /** * Gets or sets the directory to save the components of this set. */ get Directory() { return this.directory; } set Directory(value) { this.directory = value; } /** * Serializes the instruction-set to an xml dom-element. */ Serialize() { let document = XML_1.XML.CreateDocument("instructions"); let editor = new XMLEditor_1.XMLEditor(document.documentElement); editor.SetAttribute("type", "install"); for (let instruction of this) { if (!util_1.isNullOrUndefined(instruction.Compiler)) { let childNodes = instruction.Compiler.Serialize().childNodes; for (let i = 0; i < childNodes.length; i++) { let node = childNodes.item(i); editor.Add(node); } } } return editor.Element; } /** * @inheritdoc */ GetParent(child) { return child.Collection; } /** * @inheritdoc */ SetParent(child, parent) { child.Collection = parent; } } exports.InstructionSet = InstructionSet; //# sourceMappingURL=InstructionSet.js.map