public SNode Deserialize(string st) { if (st == null) { throw new ArgumentNullException(st); } else if (st.Length < 2) { throw new ArgumentException(st); } var node = new SNodeFull(false); Deserialize(ref st, node); return(node); }
private int Deserialize(ref string st, SNodeFull root) { st = st.Trim(TrimArr); st = RemoveComment(st); if (string.IsNullOrEmpty(st)) { return(0); } SNodeFull node = null; SNodeFull r = root; do { if (st[0] == ')') { st = st.Remove(0, 1); if (r.RootNode == null) { throw new Exception(ErrorStrNotValidFormat); } return(1); } else if (st[0] == '(') { st = st.Remove(0, 1); node = new SNodeFull(false); r.AddNode(node); var x = Deserialize(ref st, node); if (x != 1) { throw new Exception(ErrorStrNotValidFormat); } } else { node = DeserializeItem(ref st); r.AddNode(node); } st = st.Trim(TrimArr); st = RemoveComment(st); }while (st.Length > 0); return(0); }
public void AddNode(SNodeFull node) { base.AddNode(node); node.RootNode = this; }