public static ActItem Clone(ActItem src) { ActItem item = (ActItem)Activator.CreateInstance(src.GetType()); FieldInfo[] fields = item.GetType().GetFields(); for (int i = 0; i < fields.Length; i++) { FieldInfo newField = fields[i]; if (newField.IsDefined(typeof(SerializeField), true) && newField.IsDefined(typeof(ActFieldAttribute), true) == false) { FieldInfo oldField = src.GetType().GetField(newField.Name); if (oldField != null) { newField.SetValue(item, oldField.GetValue(src)); } } } for (int i = 0; i < src.Children.Count; i++) { ActItem child = Clone(src.Children[i]); item.AddChild(child); } return(item); }
public override void SaveDoc(XmlDocument doc, XmlElement element) { base.SaveDoc(doc, element); for (int i = 0; i < Children.Count; i++) { ActItem act = Children[i]; XmlElement child = doc.CreateElement(act.GetType().Name); element.AppendChild(child); act.SaveDoc(doc, child); } }