public void NonExistingVariable() { var scope = new Scope(); using (var trans = new ObjectTransaction()) { trans.Register(new ScopeTransactionAdapter(scope, "t1")); scope["t1"] = 42; Assert.AreEqual(42, scope["t1"]); } Assert.IsFalse(scope.Variables.Contains("t1")); }
public void NonExistingVariable() { var scope = new Scope(); using ( var trans = new ObjectTransaction() ) { trans.Register( new ScopeTransactionAdapter( scope, "t1" ) ); scope[ "t1" ] = 42; Assert.AreEqual( 42, scope[ "t1" ] ); } Assert.IsFalse( scope.Variables.Contains( "t1" ) ); }
public void ExistingVariable() { var scope = new Scope(); scope[ "t1" ] = 23; using ( var trans = new ObjectTransaction() ) { trans.Register( new ScopeTransactionAdapter( scope, "t1" ) ); scope[ "t1" ] = 42; Assert.AreEqual( 42, scope[ "t1" ] ); } Assert.AreEqual( 23, scope[ "t1" ] ); }
public void ExistingVariable() { var scope = new Scope(); scope["t1"] = 23; using (var trans = new ObjectTransaction()) { trans.Register(new ScopeTransactionAdapter(scope, "t1")); scope["t1"] = 42; Assert.AreEqual(42, scope["t1"]); } Assert.AreEqual(23, scope["t1"]); }
public void CompleteScope() { var scope = new Scope(); scope[ "t1" ] = 21; using ( var trans = new ObjectTransaction() ) { trans.Register( new ScopeTransactionAdapter( scope ) ); scope[ "t1" ] = 42; // overwrite value scope[ "t2" ] = 42; // new variable Assert.AreEqual( 42, scope[ "t1" ] ); Assert.AreEqual( 42, scope[ "t2" ] ); } Assert.AreEqual( 21, scope[ "t1" ] ); Assert.IsFalse( scope.Variables.Contains( "t2" ) ); }
public static SingleResultValue <T> FetchSingle <T>(this IMslScript script, string isin, string datum) { var provider = Interpreter.Context.DatumProviderFactory.Create(datum); if (provider == null) { throw new Exception("No data provider found for datum '" + datum + "'"); } // as we have no real stock yet (we might in process of fetching standing data // to get such stock) so we have to overwrite default lookup behaviour using (var trans = new ObjectTransaction()) { trans.Register(new ScopeTransactionAdapter(Interpreter.Context.Scope)); Interpreter.Context.Scope["stock.isin"] = isin; return(provider.FetchSingle <T>()); } }
public void CompleteScope() { var scope = new Scope(); scope["t1"] = 21; using (var trans = new ObjectTransaction()) { trans.Register(new ScopeTransactionAdapter(scope)); scope["t1"] = 42; // overwrite value scope["t2"] = 42; // new variable Assert.AreEqual(42, scope["t1"]); Assert.AreEqual(42, scope["t2"]); } Assert.AreEqual(21, scope["t1"]); Assert.IsFalse(scope.Variables.Contains("t2")); }
public static void Register(this ObjectTransaction trans, Type ns, string key) { trans.Register(Engine.ServiceProvider.ConfigurationSC().CreateAccessor(ns, key)); }