using System; using System.Collections.Generic; using System.ComponentModel; using System.Text; using System.Xml; using JWH; using JWH.DATA; namespace DDUtilityApp.TIBRENDEZVOUS.DATA { public class Server : DataTableBase { public string Name { get; set; } = string.Empty; public List TargetServers { get; set; } = new List(); [ReadOnly(true)] public string Description { get { return $"{this.Name}"; } } public Server() { } public Server(string name) { this.Name = name; } public Server(XmlNode node) { try { node.PropertiesCopyAttribute(this); XmlNode[] nodes = null; // TargetServers nodes = node.GetNodesByName("TargetServer"); foreach (XmlNode item in nodes) this.TargetServers.Add(new TargetServer(item)); } catch (Exception ex) { XLogger.Instance.Fatal(ex); } } public string ToXmlString(string indent = "") { try { string indent02 = $"{indent} "; string indent04 = $"{indent02} "; StringBuilder sb = new StringBuilder(); sb.AppendLine($"{indent}<{this.GetType().Name} Name=\"{this.Name}\">"); // TargetServers sb.AppendLine($"{indent02}"); foreach (TargetServer value in this.TargetServers) sb.Append(value.ToXmlString(indent04)); sb.AppendLine($"{indent02}"); sb.AppendLine($"{indent}"); return sb.ToString(); } catch (Exception ex) { XLogger.Instance.Fatal(ex); throw ex; } } public override string ToString() { return $"{this.Name}"; } } }