Пример #1
0
        private static void SetValue(DotExpression expression, object value, IBindingEnvironment environment)
        {
            if (expression.Arguments != null)
            {
                throw new InvalidOperationException("Invalid left value");
            }

            object obj = ResolveToObject(expression.Expression, environment);

            ObjectUtilities.SetValue(obj, expression.Name, value);
        }
Пример #2
0
        private static IDictionary ResolveToDictionary(DotExpression expression, IBindingEnvironment environment)
        {
            object obj = ResolveToObject(expression.Expression, environment);

            if (obj is DynamicObject)
            {
                DynamicObject dynobj = (DynamicObject)obj;

                obj = dynobj.GetValue(expression.Name);

                if (obj == null)
                {
                    obj = new Hashtable();
                    dynobj.SetValue(expression.Name, obj);
                }

                return((IDictionary)obj);
            }

            return((IDictionary)ObjectUtilities.GetValue(obj, expression.Name));
        }
Пример #3
0
        private static IList ResolveToList(DotExpression expression, IBindingEnvironment environment)
        {
            object obj = ResolveToObject(expression.Expression, environment);

            if (obj is DynamicObject)
            {
                DynamicObject dynobj = (DynamicObject)obj;

                obj = dynobj.GetValue(expression.Name);

                if (obj == null)
                {
                    obj = new ArrayList();
                    dynobj.SetValue(expression.Name, obj);
                }

                return((IList)obj);
            }

            return((IList)ObjectUtilities.GetValue(obj, expression.Name));
        }