public override void Execute(Machine machine, ValueEnvironment environment)
        {
            string name = EvaluateUtilities.EvaluateAsName(this.nameExpression, environment);

            string commandText = null;

            if (this.commandExpression != null)
            {
                commandText = (string)this.commandExpression.Evaluate(environment);
            }

            Database database = (Database)environment.GetValue(ValueEnvironment.CurrentDatabase);

            WorkArea workarea;

            if (commandText != null)
            {
                IDbCommand command = database.ProviderFactory.CreateCommand();
                command.CommandText = commandText;
                command.Connection  = database.GetConnection();
                workarea            = new WorkArea(name, command, database.ProviderFactory);
            }
            else
            {
                workarea = new WorkArea(name, database.GetConnection(), database.ProviderFactory);
            }

            environment.SetPublicValue(name, workarea);
            environment.SetPublicValue(ValueEnvironment.CurrentWorkArea, workarea);
        }
Beispiel #2
0
        public void RaiseIfNoPublicEnvironmentInSetPublicValue()
        {
            ValueEnvironment parent      = new ValueEnvironment();
            ValueEnvironment environment = new ValueEnvironment(parent);

            environment.SetPublicValue("foo", "bar");
        }
Beispiel #3
0
        public void SetAndGetPublicValue()
        {
            ValueEnvironment parent      = new ValueEnvironment(ValueEnvironmentType.Public);
            ValueEnvironment environment = new ValueEnvironment(parent);

            environment.SetPublicValue("foo", "bar");

            Assert.AreEqual("bar", environment.GetValue("foo"));
            Assert.AreEqual("bar", parent.GetValue("foo"));

            Assert.AreEqual("bar", environment.GetValue("FOO"));
            Assert.AreEqual("bar", parent.GetValue("FOO"));
        }
        public override void Execute(Machine machine, ValueEnvironment environment)
        {
            string name = EvaluateUtilities.EvaluateAsName(this.nameExpression, environment);

            string connectionString = null;

            if (this.connectionExpression != null)
            {
                connectionString = (string)this.connectionExpression.Evaluate(environment);
            }

            string providerName = null;

            if (this.providerExpression != null)
            {
                providerName = (string)this.providerExpression.Evaluate(environment);
            }

            Database database = new Database(name, providerName, connectionString);

            environment.SetPublicValue(name, database);
            environment.SetPublicValue(ValueEnvironment.CurrentDatabase, database);
        }
Beispiel #5
0
        public void DefineSetAndGetPublicValue()
        {
            ValueEnvironment parent      = new ValueEnvironment(ValueEnvironmentType.Public);
            ValueEnvironment environment = new ValueEnvironment(parent);

            environment.SetPublicValue("foo", null);

            environment.SetValue("foo", "bar");
            environment.SetValue("one", 1);

            Assert.AreEqual("bar", environment.GetValue("foo"));
            Assert.AreEqual("bar", parent.GetValue("foo"));

            Assert.AreEqual(1, environment.GetValue("one"));
            Assert.IsNull(parent.GetValue("one"));
        }
        public override void Execute(Machine machine, ValueEnvironment environment)
        {
            Procedure procedure = new Procedure(this.name, this.parameterNames, this.command, machine);

            environment.SetPublicValue(this.name, procedure);
        }