Exemplo n.º 1
0
        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"));
        }
Exemplo n.º 2
0
        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" ) );
        }
Exemplo n.º 3
0
        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" ] );
        }
Exemplo n.º 4
0
        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"]);
        }
Exemplo n.º 5
0
        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" ) );
        }
Exemplo n.º 6
0
        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>());
            }
        }
Exemplo n.º 7
0
        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"));
        }
Exemplo n.º 8
0
 public static void Register(this ObjectTransaction trans, Type ns, string key)
 {
     trans.Register(Engine.ServiceProvider.ConfigurationSC().CreateAccessor(ns, key));
 }