private static void SerializeCommandsRecursively(TreeNode<YamlObject> parent, TreeNode<Command> commandToAdd, int level) { var commandYamlObject = YamlCommandIO.Serialize(commandToAdd.value, level); parent.Join(commandYamlObject); foreach (var childNode in commandToAdd) SerializeCommandsRecursively(commandYamlObject, childNode, level + 1); }
private static void DeserializeCommandsRecursively(TreeNode<Command> commandRoot, TreeNode<YamlObject> yamlCommandNode) { var command = YamlCommandIO.Deserialize(yamlCommandNode); if (command == null) return; var addedCommandNode = commandRoot.AddChild(command); foreach (var yamlChildCommand in yamlCommandNode) { // Don't call Deserialize for non-command properties. In Yaml tree Command properties don't have any value, just property name. if (yamlChildCommand.value.value == "" || yamlChildCommand.value.value == string.Empty) DeserializeCommandsRecursively(addedCommandNode, yamlChildCommand); } }