Exemple #1
0
        private void Configure(ConfigParts configParts)
        {
            try
            {
                HashSet <Type> moduleTypes = new HashSet <Type>();
                using (Trace.WithIndent().Verbose("Initializing scripting environment"))
                {
                    _assemblyManager.Initialize(_assemblyCollection, _packages, _fileSystem);
                    moduleTypes = _assemblyManager.GetModuleTypes();
                }

                using (Trace.WithIndent().Verbose("Evaluating configuration script"))
                {
                    _configScript = new ConfigScript(configParts.Declarations, configParts.Config, moduleTypes,
                                                     _assemblyManager.Namespaces);
                    OutputScript(ConfigScript.AssemblyName, _configScript.Code);
                    _configScript.Compile(_assemblyManager.Assemblies);
                    _configScript.Invoke(_engine);
                }
            }
            catch (TargetInvocationException ex)
            {
                Trace.Error("Error during configuration evaluation: {0}", ex.InnerException.Message);
                throw;
            }
            catch (Exception ex)
            {
                Trace.Error("Error during configuration evaluation: {0}", ex.Message);
                throw;
            }
        }
Exemple #2
0
        // Setup is separated from config by a line with only '-' characters
        // If no such line exists, then the entire script is treated as config
        public void Configure(string script, bool updatePackages, string fileName, bool outputScripts)
        {
            CheckDisposed();
            if (Configured)
            {
                throw new InvalidOperationException("This engine has already been configured.");
            }
            Configured     = true;
            _fileName      = fileName;
            _outputScripts = outputScripts;

            // If no script, nothing else to do
            if (string.IsNullOrWhiteSpace(script))
            {
                Configure(new ConfigParts(null, null, null));
                return;
            }

            ConfigParts configParts = ConfigSplitter.Split(script);

            // Setup (install packages, specify additional assemblies, etc.)
            if (!string.IsNullOrWhiteSpace(configParts.Setup))
            {
                Setup(configParts, updatePackages);
            }

            // Configuration
            Configure(configParts);
        }
Exemple #3
0
        private void Setup(ConfigParts configParts, bool updatePackages)
        {
            try
            {
                // Compile and evaluate the script
                using (Trace.WithIndent().Verbose("Evaluating setup script"))
                {
                    SetupScript setupScript = new SetupScript(configParts.Setup);
                    OutputScript(SetupScript.AssemblyName, setupScript.Code);
                    setupScript.Compile();
                    setupScript.Invoke(_packages, _assemblyCollection, _fileSystem);
                }

                // Install packages
                using (Trace.WithIndent().Verbose("Installing packages"))
                {
                    _packages.InstallPackages(updatePackages);
                }
            }
            catch (Exception ex)
            {
                Trace.Error("Unexpected error during setup: {0}", ex.Message);
                throw;
            }
        }
Exemple #4
0
        private void Setup(ConfigParts configParts, bool updatePackages)
        {
            try
            {
                // Compile and evaluate the script
                using (Trace.WithIndent().Verbose("Evaluating setup script"))
                {
                    SetupScript setupScript = new SetupScript(configParts.Setup);
                    OutputScript(SetupScript.AssemblyName, setupScript.Code);
                    setupScript.Compile();
                    setupScript.Invoke(_packages, _assemblyCollection, _fileSystem);
                }

                // Install packages
                using (Trace.WithIndent().Verbose("Installing packages"))
                {
                    _packages.InstallPackages(updatePackages);
                }
            }
            catch (Exception ex)
            {
                Trace.Error("Unexpected error during setup: {0}", ex.Message);
                throw;
            }
        }
Exemple #5
0
        private void Configure(ConfigParts configParts)
        {
            try
            {
                HashSet<Type> moduleTypes = new HashSet<Type>();
                using (Trace.WithIndent().Verbose("Initializing scripting environment"))
                {
                    _assemblyManager.Initialize(_assemblyCollection, _packages, _fileSystem);
                    moduleTypes = _assemblyManager.GetModuleTypes();
                }

                using (Trace.WithIndent().Verbose("Evaluating configuration script"))
                {
                    _configScript = new ConfigScript(configParts.Declarations, configParts.Config, moduleTypes,
                        _assemblyManager.Namespaces);
                    OutputScript(ConfigScript.AssemblyName, _configScript.Code);
                    _configScript.Compile(_assemblyManager.Assemblies);
                    _configScript.Invoke(_engine);
                }
            }
            catch (TargetInvocationException ex)
            {
                Trace.Error("Error during configuration evaluation: {0}", ex.InnerException.Message);
                throw;
            }
            catch (Exception ex)
            {
                Trace.Error("Error during configuration evaluation: {0}", ex.Message);
                throw;
            }
        }