Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
 /// <summary> Ctor.</summary>
 /// <param name="propertyName">is the name of the property
 /// </param>
 protected PropertyBase(String propertyName)
 {
     PropertyNameAtomic = PropertyParser.UnescapeBacktick(propertyName);
 }