public object Get(EventBean eventBean)
 {
     if (eventBean.Underlying is XNode xnode)
     {
         var result = _getter.GetValueAsNode(xnode);
         if (result != null)
         {
             return(GetParseTextValue(result, _parser));
         }
         return(null);
     }
     else if (eventBean.Underlying is XmlNode xmlnode)
     {
         var result = _getter.GetValueAsNode(xmlnode);
         if (result != null)
         {
             return(GetParseTextValue(result, _parser));
         }
         return(null);
     }
     else
     {
         throw new PropertyAccessException("Mismatched property getter to event bean type, " +
                                           "the underlying data object is not of type Node");
     }
 }
Example #2
0
        public object Get(EventBean obj)
        {
            // The underlying is expected to be a map
            if (!(obj.Underlying is XmlNode)) {
                throw new PropertyAccessException(
                    "Mismatched property getter to event bean type, " +
                    "the underlying data object is not of type Node");
            }

            var node = (XmlNode) obj.Underlying;
            var result = getter.GetValueAsNode(node);
            return GetParseTextValue(result, parser);
        }
Example #3
0
        public Object Get(EventBean eventBean)
        {
            var asXNode = eventBean.Underlying as XNode;

            if (asXNode == null)
            {
                var asXml = eventBean.Underlying as XmlNode;
                if (asXml == null)
                {
                    throw new PropertyAccessException("Mismatched property getter to event bean type, " +
                                                      "the underlying data object is not of type Node");
                }

                XmlNode result = _getter.GetValueAsNode(asXml);
                if (result == null)
                {
                    return(null);
                }

                return(_parser.Invoke(result.InnerText));
            }
            else
            {
                XObject result = _getter.GetValueAsNode(asXNode);
                if (result == null)
                {
                    return(null);
                }

                if (result is XElement)
                {
                    return(_parser.Invoke(((XElement)result).Value));
                }

                return(_parser.Invoke(result.ToString()));
            }
        }