Ejemplo n.º 1
0
        public void PropertyPathWillEvaluateFieldsAndProperties()
        {
            var          data = TestHelper.CreateSinglePage();
            PropertyPath path = data.ParsePropertyPath("PageNumber");

            Assert.That(path.Evaluate(data), Is.EqualTo(15));
        }
Ejemplo n.º 2
0
        public override CurrentItemsCollection FillDataRow(int pos)
        {
            CurrentItemsCollection ci = new CurrentItemsCollection();
            var obj = CurrentFromPosition(pos);

            if (obj != null)
            {
                CurrentItem currentItem = null;
                foreach (PropertyDescriptor pd in this.listProperties)
                {
                    currentItem = new CurrentItem(pd.Name, pd.PropertyType);
                    PropertyPath prop = obj.ParsePropertyPath(pd.Name);
                    if (prop != null)
                    {
                        var pp = prop.Evaluate(obj);
                        if (pp != null)
                        {
                            currentItem.Value = pp.ToString();
                        }
                    }
                    ci.Add(currentItem);
                }
            }
            return(ci);
        }
        private void VariableStore(object sender, SimpleExpressionEvaluator.Evaluation.UnknownVariableEventArgs e)
        {
            PropertyPath path = this.singlePage.ParsePropertyPath(e.VariableName);

            if (path != null)
            {
                e.VariableValue = path.Evaluate(path);
            }

            // Look in Parametershash
            if (singlePage.ParameterHash.ContainsKey(e.VariableName))
            {
                try {
                    e.VariableValue = singlePage.ParameterHash[e.VariableName].ToString();
                }
                catch (Exception)
                {
                    e.VariableValue = String.Empty;
                    Console.WriteLine("");
                    Console.WriteLine("ExpressionEvaluatorFacade.VariableStore");
                    Console.WriteLine("Replace Param <{0}> with String.Empty because no value is set", e.VariableName);
                    Console.WriteLine("");
                }
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Processes a Property Path
 /// </summary>
 /// <param name="path">Path</param>
 /// <param name="context">SPARQL Evaluation Context</param>
 /// <returns></returns>
 public virtual BaseMultiset ProcessPropertyPath(PropertyPath path, SparqlEvaluationContext context)
 {
     if (context == null)
     {
         context = this.GetContext();
     }
     return(path.Evaluate(context));
 }
Ejemplo n.º 5
0
        private void VariableStore(object sender, SimpleExpressionEvaluator.Evaluation.UnknownVariableEventArgs e)
        {
            PropertyPath path = this.singlePage.ParsePropertyPath(e.VariableName);

            if (path != null)
            {
                e.VariableValue = path.Evaluate(path);
            }
            // Look in Parametershash
            if (singlePage.ParameterHash.ContainsKey(e.VariableName))
            {
                e.VariableValue = singlePage.ParameterHash[e.VariableName].ToString();
            }
        }
        private void FunctionStore(object sender, SimpleExpressionEvaluator.Evaluation.UnknownFunctionEventArgs e)
        {
            PropertyPath path      = null;
            object       searchObj = null;

            path = e.ContextObject.ParsePropertyPath(e.FunctionName);
            if (path != null)
            {
                searchObj = e.ContextObject;
            }
            else
            {
                throw new UnknownFunctionException(e.FunctionName);
            }
            e.Function = functionArgs => path.Evaluate(searchObj);
        }
        private void FunctionStore(object sender, SimpleExpressionEvaluator.Evaluation.UnknownFunctionEventArgs e)
        {
            PropertyPath path      = null;
            object       searchObj = null;

            path = e.ContextObject.ParsePropertyPath(e.FunctionName);
            if (path != null)
            {
                searchObj = e.ContextObject;
            }
            else
            {
                throw new InvalidOperationException("A function specified in the expression (" + e.FunctionName +
                                                    ") does not exist.");
            }
            e.Function = functionArgs => path.Evaluate(searchObj);
        }
Ejemplo n.º 8
0
        public static void Run()
        {
            var item = new Item
            {
                Uid         = "uid",
                DisplayName = "display name"
            };

            var propname = nameof(item.Uid);

            var path = new PropertyPath("Uid.Length");
            var key2 = path.Evaluate(item);


            // one way...
            var prop = item.GetType().GetProperty(propname);

            var getter = prop.AsGetter <object, object>();
            var key    = getter(item);
        }
        protected virtual object ResolveQualifiedName(Type targetType, object target, string[] name)
        {
            string       cacheKey = PropertyPath.GetCacheKey(targetType, name);
            PropertyPath path     = null;

            _propCache.TryGetValue(cacheKey, out path);

            if (path == null)
            {
                path = PropertyPath.Compile(targetType, name);
                if (path != null)
                {
                    _propCache[cacheKey] = path;
                }
            }

            if (path != null)
            {
                return(path.Evaluate(target));
            }
            return(null);
        }
Ejemplo n.º 10
0
        private void FillInternal(object fillFrom, IDataItem item)
        {
            if (item is BaseDataItem)
            {
                string       result = String.Empty;
                PropertyPath path   = fillFrom.ParsePropertyPath(item.ColumnName);
                if (path != null)
                {
                    var pp = path.Evaluate(fillFrom);
                    if (pp != null)
                    {
                        result = pp.ToString();
                    }
                }
                else
                {
                    result = WrongColumnName(item.ColumnName);
                }

                item.DBValue = result;
            }
            else
            {
                //image processing from IList
                BaseImageItem baseImageItem = item as BaseImageItem;

                if (baseImageItem != null)
                {
                    PropertyDescriptor p = this.listProperties.Find(baseImageItem.ColumnName, true);
                    if (p != null)
                    {
                        baseImageItem.Image = p.GetValue(this.Current) as System.Drawing.Image;
                    }
                    return;
                }
            }
        }