Exemplo n.º 1
0
        public void Parse(string xml)
        {
            if (string.IsNullOrEmpty(xml))
            {
                return;
            }

            var elementName  = string.Empty;
            var elementStart = false;

            foreach (var symbol in xml)
            {
                if (symbol == '<')
                {
                    elementStart = true;
                }
                else if (symbol == '>' || char.IsWhiteSpace(symbol))
                {
                    break;
                }
                else if (elementStart)
                {
                    elementName += symbol;
                }
            }

            if (actions.ContainsKey(elementName))
            {
                actions[elementName].Value.DynamicInvoke(NXmlDeserializer.Deserialize(actions[elementName].Key, xml));
            }
        }
Exemplo n.º 2
0
        private Result SendCommand(Command command)
        {
            var commandStr = command.ToString();

            OnLogging(commandStr);

            var resultStr = NXmlConnector.SendCommand(commandStr);

            OnLogging(resultStr);
            var result = (Result)NXmlDeserializer.Deserialize(typeof(Result), resultStr);

            if (!result.Success)
            {
                throw new NXmlConnectorException(result.ErrorText);
            }
            return(result);
        }