Example #1
0
        public virtual object Execute(ModelData data, IServiceLocator services)
        {
            _expander.PushContext(new VariableExpanderContext(data, new Dictionary <string, object>()));

            try
            {
                var arguments = new TransformArguments(_services, _arguments.ToDictionary(_ => _.Name, _ => _.Resolve(data)));
                var context   = new TransformContext(data, arguments, services);
                var value     = _transform.Execute(context);

                if (value is IDynamicValue)
                {
                    value = value.As <IDynamicValue>().Resolve(_services);
                }

                if (value != null)
                {
                    _path.Set(data, value);
                }

                return(value);
            }
            finally
            {
                _expander.PopContext();
            }
        }
Example #2
0
 public void Visit(PushVariableContext instruction)
 {
     executeInstruction(() =>
     {
         _expander.PushContext(new VariableExpanderContext(null,
                                                           instruction.Attributes.ToDictionary(_ => _.Key, _ => _.Value.Resolve(_services))));
     });
 }