public virtual UnitOptionRow Serialize() { var row = new UnitOptionRow(); if (sourceScriptGuids.Count == 0) { // Important to set to null here, because the code relies on // null checks, not empty string checks. row.sourceScriptGuids = null; } else { row.sourceScriptGuids = string.Join(",", sourceScriptGuids.ToArray()); } row.optionType = Codebase.SerializeType(GetType()); row.unitType = Codebase.SerializeType(unitType); row.unit = unit.Serialize().json; row.category = category?.fullName; row.labelHuman = labelHuman; row.labelProgrammer = labelProgrammer; row.order = order; row.haystackHuman = haystackHuman; row.haystackProgrammer = haystackProgrammer; row.favoriteKey = favoriteKey; row.controlInputCount = controlInputCount; row.controlOutputCount = controlOutputCount; row.valueInputTypes = valueInputTypes.Select(Codebase.SerializeType).ToSeparatedString("|").NullIfEmpty(); row.valueOutputTypes = valueOutputTypes.Select(Codebase.SerializeType).ToSeparatedString("|").NullIfEmpty(); return(row); }
public override void Deserialize(UnitOptionRow row) { base.Deserialize(row); kind = (VariableKind)Enum.Parse(typeof(VariableKind), row.tag1); name = row.tag2; }
public virtual void Deserialize(UnitOptionRow row) { source = row; if (row.sourceScriptGuids != null) { sourceScriptGuids = row.sourceScriptGuids.Split(',').ToHashSet(); } unitType = Codebase.DeserializeType(row.unitType); category = row.category == null ? null : new UnitCategory(row.category); labelHuman = row.labelHuman; labelProgrammer = row.labelProgrammer; order = row.order; haystackHuman = row.haystackHuman; haystackProgrammer = row.haystackProgrammer; favoriteKey = row.favoriteKey; controlInputCount = row.controlInputCount; controlOutputCount = row.controlOutputCount; }
public override void Deserialize(UnitOptionRow row) { base.Deserialize(row); literalType = Codebase.DeserializeType(row.tag1); }