Various fixes

This commit is contained in:
barsdeveloper
2021-10-27 19:27:19 +02:00
parent 56c23fc192
commit 418630255e
41 changed files with 2401 additions and 2337 deletions

View File

@@ -0,0 +1,46 @@
import ObjectEntity from "../entity/ObjectEntity"
import PinEntity from "../entity/PinEntity"
import Serializer from "./Serializer"
import SerializerFactory from "./SerializerFactory"
export default class ObjectSerializer extends Serializer {
constructor() {
super(ObjectEntity, " ", "\n", false)
}
showProperty(attributeKey, attributeValue) {
switch (attributeKey.toString()) {
case "Class":
case "Name":
case "CustomProperties":
// Serielized separately
return false
}
return super.showProperty(attributeKey, attributeValue)
}
read(value) {
const parseResult = Serializer.grammar.Object.parse(value)
if (!parseResult.status) {
console.error("Error when trying to parse the object.")
return parseResult
}
return parseResult.value
}
/**
*
* @param {ObjectEntity} object
* @returns
*/
write(object) {
let result = `Begin Object Class=${object.Class} Name=${object.Name}
${this.subWrite([], object)
+ object
.CustomProperties.map(pin => this.separator + this.prefix + "CustomProperties " + SerializerFactory.getSerializer(PinEntity).write(pin))
.join("")}
End Object`
return result
}
}