public void Execute(IBindingEnvironment environment) { IBindingEnvironment newenv = environment; if (this.localvar) { newenv = new LocalBindingEnvironment(environment); newenv.SetLocalValue(this.name, null); } foreach (object result in (IEnumerable)this.expression.Evaluate(newenv)) { newenv.SetValue(this.name, result); this.command.Execute(newenv); } }
public void SetValueThruLocalAndNormalEnviroment() { BindingEnvironment parent = new BindingEnvironment(); LocalBindingEnvironment toplocal = new LocalBindingEnvironment(parent); toplocal.SetLocalValue("one", 0); BindingEnvironment environment = new BindingEnvironment(toplocal); LocalBindingEnvironment local = new LocalBindingEnvironment(environment); local.SetValue("one", 1); Assert.AreEqual(1, local.GetValue("one")); Assert.AreEqual(1, environment.GetValue("one")); Assert.AreEqual(1, toplocal.GetValue("one")); Assert.IsNull(parent.GetValue("one")); }