protected override EventPropertyGetter DoResolvePropertyGetter(String propertyExpression) { var getter = _propertyGetterCache.Get(propertyExpression); if (getter != null) { return(getter); } if (!ConfigurationEventTypeXMLDOM.IsXPathPropertyExpr) { var prop = PropertyParser.ParseAndWalkLaxToSimple(propertyExpression); getter = prop.GetGetterDOM(); if (!prop.IsDynamic) { getter = new DOMConvertingGetter(propertyExpression, (DOMPropertyGetter)getter, typeof(string)); } } else { try { var ast = PropertyParser.Parse(propertyExpression); var isDynamic = PropertyParser.IsPropertyDynamic(ast); var xPathExpr = SimpleXMLPropertyParser.Walk( ast, propertyExpression, RootElementName, _defaultNamespacePrefix, _isResolvePropertiesAbsolute); if (Log.IsInfoEnabled) { Log.Info("Compiling XPath expression for property '" + propertyExpression + "' as '" + xPathExpr + "'"); } var xPathExpression = XPathExpression.Compile(xPathExpr, NamespaceContext); var xPathReturnType = isDynamic ? XPathResultType.Any : XPathResultType.String; getter = new XPathPropertyGetter( propertyExpression, xPathExpr, xPathExpression, xPathReturnType, null, null); } catch (XPathException e) { throw new EPException( "Error constructing XPath expression from property name '" + propertyExpression + '\'', e); } } // no fragment factory, fragments not allowed _propertyGetterCache.Put(propertyExpression, getter); return(getter); }
private EventPropertyGetter DoResolvePropertyGetter(String propertyExpression, bool allowSimpleProperties) { EventPropertyGetter getter = _propertyGetterCache.Get(propertyExpression); if (getter != null) { return(getter); } if (!allowSimpleProperties) { // see if this is an indexed property int index = ASTUtil.UnescapedIndexOfDot(propertyExpression); if (index == -1) { // parse, can be an indexed property Property property = PropertyParser.ParseAndWalkLaxToSimple(propertyExpression); if (!property.IsDynamic) { if (!(property is IndexedProperty)) { return(null); } var indexedProp = (IndexedProperty)property; getter = PropertyGetters.Get(indexedProp.PropertyNameAtomic); if (null == getter) { return(null); } EventPropertyDescriptor descriptor = PropertyDescriptorMap.Get(indexedProp.PropertyNameAtomic); if (descriptor == null) { return(null); } if (!descriptor.IsIndexed) { return(null); } if (descriptor.PropertyType == typeof(XmlNodeList)) { FragmentFactory fragmentFactory = new FragmentFactoryDOMGetter( EventAdapterService, this, indexedProp.PropertyNameAtomic); return(new XPathPropertyArrayItemGetter(getter, indexedProp.Index, fragmentFactory)); } if (descriptor.PropertyType == typeof(string)) { FragmentFactory fragmentFactory = new FragmentFactoryDOMGetter( EventAdapterService, this, indexedProp.PropertyNameAtomic); return(new XPathPropertyArrayItemGetter(getter, indexedProp.Index, fragmentFactory)); } } } } if (!_isPropertyExpressionXPath) { Property prop = PropertyParser.ParseAndWalkLaxToSimple(propertyExpression); bool isDynamic = prop.IsDynamic; if (!isDynamic) { SchemaItem item = prop.GetPropertyTypeSchema(_schemaModelRoot, EventAdapterService); if (item == null) { return(null); } getter = prop.GetGetterDOM(_schemaModelRoot, EventAdapterService, this, propertyExpression); if (getter == null) { return(null); } Type returnType = SchemaUtil.ToReturnType(item); if ((returnType != typeof(XmlNode)) && (returnType != typeof(XmlNodeList))) { if (!returnType.IsArray) { getter = new DOMConvertingGetter(propertyExpression, (DOMPropertyGetter)getter, returnType); } else { getter = new DOMConvertingArrayGetter((DOMPropertyGetter)getter, returnType.GetElementType()); } } } else { return(prop.GetGetterDOM()); } } else { bool allowFragments = !ConfigurationEventTypeXMLDOM.IsXPathPropertyExpr; getter = SchemaXMLPropertyParser.GetXPathResolution( propertyExpression, NamespaceContext, RootElementName, _rootElementNamespace, _schemaModel, EventAdapterService, this, allowFragments, ConfigurationEventTypeXMLDOM.DefaultNamespace); } _propertyGetterCache.Put(propertyExpression, getter); return(getter); }