mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-27 18:54:44 +08:00
Bugfixes, LocalizedText is an entity again
This commit is contained in:
@@ -11,17 +11,20 @@ export default class Serializer {
|
||||
|
||||
static grammar = Parsimmon.createLanguage(new Grammar())
|
||||
|
||||
constructor(entityType, prefix = "", separator = ",", trailingSeparator = false) {
|
||||
constructor(entityType, prefix, separator, trailingSeparator, attributeValueConjunctionSign, attributeKeyPrinter) {
|
||||
this.entityType = entityType
|
||||
this.prefix = prefix
|
||||
this.separator = separator
|
||||
this.trailingSeparator = trailingSeparator
|
||||
this.prefix = prefix ?? ""
|
||||
this.separator = separator ?? ","
|
||||
this.trailingSeparator = trailingSeparator ?? false
|
||||
this.attributeValueConjunctionSign = attributeValueConjunctionSign ?? "="
|
||||
this.attributeKeyPrinter = attributeKeyPrinter ?? (k => k.join("."))
|
||||
}
|
||||
|
||||
writeValue(value) {
|
||||
if (value === null) {
|
||||
return "()"
|
||||
}
|
||||
// This is an exact match (and not instanceof) to hit also primitive types (by accessing value.constructor they are converted to objects automatically)
|
||||
switch (value?.constructor) {
|
||||
case Function:
|
||||
return this.writeValue(value())
|
||||
@@ -51,7 +54,11 @@ export default class Serializer {
|
||||
// Recursive call when finding an object
|
||||
result += this.subWrite(fullKey, value, this.prefix, this.separator)
|
||||
} else if (this.showProperty(fullKey, value)) {
|
||||
result += (result.length ? this.separator : "") + this.prefix + fullKey.join(".") + "=" + this.writeValue(value)
|
||||
result += (result.length ? this.separator : "")
|
||||
+ this.prefix
|
||||
+ this.attributeKeyPrinter(fullKey)
|
||||
+ this.attributeValueConjunctionSign
|
||||
+ this.writeValue(value)
|
||||
}
|
||||
}
|
||||
if (this.trailingSeparator && result.length) {
|
||||
|
||||
Reference in New Issue
Block a user