Ejemplo n.º 1
0
        public string To_XML()
        {
            if (Graphic_Type == Graphic_Types.NONE)
            {
                return("");
            }
            var ret = "<graphics type='" + Graphic_Type.ToString() + "'";

            if (autoport)
            {
                ret += " autoport='yes'";
            }
            else
            {
                ret += "' port='" + _port.ToString() + "'";
            }
            ret += (!string.IsNullOrWhiteSpace(listen) ? " listen='" + listen + "'" : "");
            ret += (!string.IsNullOrWhiteSpace(passwd) ? " passwd='" + passwd + "'" : "") + (websocket.HasValue ? " websocket='" + websocket.Value.ToString() + "'" : "");
            ret += (passwdValidTo.HasValue ? " passwdValidTo='" + System.DateTime.SpecifyKind(passwdValidTo.Value, System.DateTimeKind.Utc).ToString("yyyy-MM-ddTH:mm:ss") + "'" : "");
            if (Graphics_Listen != null)
            {
                ret += ">" + Graphics_Listen.To_XML();
                ret += "</graphics>";
            }
            else
            {
                ret += " />";
            }

            return(ret);
        }
Ejemplo n.º 2
0
        public void From_XML(System.Xml.Linq.XElement xml)
        {
            Reset();
            var element = xml.Element("graphics");

            if (element == null)
            {
                if (xml.Name == "graphics")
                {
                    element = xml;
                }
                else
                {
                    element = null;
                }
            }
            if (element != null)
            {
                var type = element.Attribute("type");
                if (type != null)
                {
                    var a = Graphic_Types.vnc;
                    Enum.TryParse(type.Value, out a);
                    Graphic_Type = a;
                }
                type = element.Attribute("port");
                if (type != null)
                {
                    var a = -1;
                    Int32.TryParse(type.Value, out a);
                    port = a;
                }
                type = element.Attribute("autoport");
                if (type != null)
                {
                    if (type.Value == "yes")
                    {
                        autoport = true;
                    }
                    else
                    {
                        autoport = false;
                    }
                }
                type = element.Attribute("passwdValidTo");
                if (type != null)
                {
                    passwdValidTo = DateTime.ParseExact(type.Value, "yyyy-MM-ddTH:mm:ss", System.Globalization.CultureInfo.InvariantCulture);
                }

                type = element.Attribute("passwd");
                if (type != null)
                {
                    passwd = type.Value;
                }
                type = element.Attribute("listen");
                if (type != null)
                {
                    listen = type.Value;
                }
                type = element.Attribute("websocket");
                if (type != null)
                {
                    int a = -1;
                    if (Int32.TryParse(type.Value, out a))
                    {
                        websocket = a;
                    }
                }
                var sublisten = element.Element("listen");
                if (sublisten != null)
                {
                    Graphics_Listen = new Graphics_Listen();
                    Graphics_Listen.From_XML(sublisten);
                }
            }
            else
            {
                Graphic_Type = Graphic_Types.NONE;
            }
        }