Exemplo n.º 1
0
        public SocketMessage(XML.Reader reader)
        {
            try
            {
                if (reader.NodeType != XmlNodeType.Element) throw new XmlException("SocketMessage Element Required");
                if (reader.Name != "SocketMessage") throw new XmlException("SocketMessage Element Required");

                this.id = reader.GetAttributeLong("id");
                this.command = reader.GetAttributeString("command");
                this.member = reader.GetAttributeString("member");
                this.fromID = reader.GetAttributeLong("from");
                this.toID = reader.GetAttributeLong("to");
                long length = reader.GetAttributeLong("len");
                this.timestamp = reader.GetAttributeTimestamp("timestamp");
                if (length > 0) reader.Read();
                this.data = reader.Value;
            }
            catch (Exception)
            {

            }
        }
Exemplo n.º 2
0
        public HttpServer(XML.Reader reader)
        {
            if (reader != null) this.Deserialize(reader);

            this.Start();
        }
Exemplo n.º 3
0
        private void Deserialize(XML.Reader reader)
        {
            try
            {
                string elementName = reader.Name;
                while (reader.Read() && (reader.NodeType != XmlNodeType.EndElement || reader.Name != elementName))
                {
                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        switch (reader.Name)
                        {
                            case "port":
                                this.port = (int)reader.GetValueLong();
                                break;

                            case "wwwroot":
                                this.root =  reader.GetValueString();
                                this.root = Path.GetFullPath(this.root);
                                break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Base.Program.Log(ex);
            }
        }
Exemplo n.º 4
0
 public void Serialize(XML.Writer writer)
 {
     writer.WriteStartElement("http-server");
     writer.WriteElement("port", this.port);
     writer.WriteElement("wwwroot", this.root);
     writer.WriteEndElement();
 }
Exemplo n.º 5
0
 protected abstract void Serialize(XML.Writer writer);
Exemplo n.º 6
0
 protected abstract void Deserialize(XML.Reader reader);
Exemplo n.º 7
0
        public void Serialize(XML.Writer writer)
        {
            writer.WriteStartElement("SocketMessage");
            writer.WriteAttributeString("id", this.id);
            writer.WriteAttributeString("command", this.command);
            writer.WriteAttributeString("member", this.member);
            writer.WriteAttributeString("from", this.fromID);
            writer.WriteAttributeString("to", this.toID);
            writer.WriteAttributeString("timestamp", this.timestamp);

            if (String.IsNullOrEmpty(this.data))
            {
                writer.WriteAttributeString("len", 0);
                writer.WriteValue("");
            }
            else
            {
                writer.WriteAttributeString("len", this.data.Length);
                writer.WriteValue(this.data);
            }

            writer.WriteEndElement();		// SocketMessage
        }