Esempio n. 1
0
        public object Evaluate(ValueEnvironment environment)
        {
            string name = EvaluateUtilities.EvaluateAsName(this.nameExpression, environment);

            object value = environment.GetValue(name);

            Type type = null;

            type = TypeUtilities.GetType(environment, name);

            object[] parameters = null;

            if (this.arguments != null && this.arguments.Count > 0)
            {
                List <object> values = new List <object>();

                foreach (IExpression argument in this.arguments)
                {
                    values.Add(argument.Evaluate(environment));
                }

                parameters = values.ToArray();
            }

            return(Activator.CreateInstance(type, parameters));
        }
        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);
        }
Esempio n. 3
0
        private static Type AsType(IExpression expression, ValueEnvironment environment)
        {
            string name = EvaluateUtilities.EvaluateAsName(expression, environment);

            if (name == null)
            {
                return(null);
            }

            return(TypeUtilities.AsType(name));
        }
        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);
        }