public void TestParse() { Property property = PropertyParser.ParseAndWalk("a", false); Assert.AreEqual("a", ((SimpleProperty)property).PropertyNameAtomic); property = PropertyParser.ParseAndWalk("i[1]", false); Assert.AreEqual("i", ((IndexedProperty)property).PropertyNameAtomic); Assert.AreEqual(1, ((IndexedProperty)property).Index); property = PropertyParser.ParseAndWalk("m('key')", false); Assert.AreEqual("m", ((MappedProperty)property).PropertyNameAtomic); Assert.AreEqual("key", ((MappedProperty)property).Key); property = PropertyParser.ParseAndWalk("a.b[2].c('m')", false); IList <Property> nested = ((NestedProperty)property).Properties; Assert.AreEqual(3, nested.Count); Assert.AreEqual("a", ((SimpleProperty)nested[0]).PropertyNameAtomic); Assert.AreEqual("b", ((IndexedProperty)nested[1]).PropertyNameAtomic); Assert.AreEqual(2, ((IndexedProperty)nested[1]).Index); Assert.AreEqual("c", ((MappedProperty)nested[2]).PropertyNameAtomic); Assert.AreEqual("m", ((MappedProperty)nested[2]).Key); property = PropertyParser.ParseAndWalk("a", true); Assert.AreEqual("a", ((DynamicSimpleProperty)property).PropertyNameAtomic); }
private String TryKey(String key) { String propertyName = "m(\"" + key + "\")"; Log.Debug(".tryKey PropertyName=" + propertyName + " key=" + key); Property property = PropertyParser.ParseAndWalk(propertyName, false); return(((MappedProperty)property).Key); }
public static string UnescapeBacktick(string unescapedPropertyName) { if (unescapedPropertyName.StartsWith("`") && unescapedPropertyName.EndsWith("`")) { return(unescapedPropertyName.Substring(1, unescapedPropertyName.Length - 2)); } if (!unescapedPropertyName.Contains("`")) { return(unescapedPropertyName); } // parse and render var property = PropertyParser.ParseAndWalkLaxToSimple(unescapedPropertyName); if (property is NestedProperty) { var writer = new StringWriter(); property.ToPropertyEPL(writer); return(writer.ToString()); } return(unescapedPropertyName); }
/// <summary> Ctor.</summary> /// <param name="propertyName">is the name of the property /// </param> protected PropertyBase(String propertyName) { PropertyNameAtomic = PropertyParser.UnescapeBacktick(propertyName); }