//append another CML data file to the end of this one virtual public bool Join(CML other, CMLCopyMode copy_mode = CMLCopyMode.no_id) { if (null == other || other.Count == 0) return false; foreach(cmlData d in other) { Elements.Add( d.Copy(copy_mode, Elements.Count.ToString()) ); } return true; }
//returns a duplicate of this cmlData object virtual public cmlData Copy(CMLCopyMode mode = CMLCopyMode.no_id, string id_value="-1") { cmlData result = new cmlData(); result.data_type = this.data_type; foreach (var data in this.defined) { if (data.Key != "id") { result.Set(data.Key, data.Value); } else { switch (mode) { //keep the original id.... case CMLCopyMode.old_id: result.Set("id", data.Value); break; case CMLCopyMode.new_id : result.Set("id", id_value); break; case CMLCopyMode.no_id : result.Remove("id"); break; } } } foreach (string s in this.data) result.data.Add(s); return result; }