private IJSONObject find(string objectName, bool autoCreateTree, IJSONObject currentParent, SOType forceType = SOType.Undefined) { //quebra o nome em um array objectName = objectName.Replace("]", "").Replace("[", "."); string currentName = objectName; string childsNames = ""; IJSONObject childOnParent; if (objectName.IndexOf('.') > -1) { currentName = objectName.Substring(0, objectName.IndexOf('.')); childsNames = objectName.Substring(objectName.IndexOf('.') + 1); } if (!(currentParent.__containsChild(currentName))) { if (autoCreateTree) { IJSONObject tempObj; string currentParentRelativeName = currentParent.getRelativeName(); if (currentParent is InMemoryJsonObject) { tempObj = new InMemoryJsonObject((InMemoryJsonObject)currentParent, currentParent.getRelativeName() + (currentParentRelativeName.Contains('.') ? "." : "") + currentName); } else { tempObj = new FileSystemJsonObject((FileSystemJsonObject)currentParent, currentParent.getRelativeName() + (currentParentRelativeName.Contains('.') ? "." : "") + currentName, (string)JsonObjectArguments); } if (forceType != SOType.Undefined) { tempObj.forceType(forceType); } currentParent.setChild(currentName, tempObj); } else { return(null); } } childOnParent = currentParent.__getChild(currentName); if (childsNames == "") { return(childOnParent); } else { return(this.find(childsNames, autoCreateTree, childOnParent)); } }
public InMemoryJsonObject(InMemoryJsonObject pParent, string relativeName) { this.relativeName = relativeName; this.parent = pParent; }