コード例 #1
0
        /// <summary>
        /// The assembly stf configuration.
        /// </summary>
        private void AssembleStfConfigurationBeforePlugins()
        {
            var stfConfigurationFile = Path.Combine(StfConfigDir, @"StfConfiguration.xml");

            if (!File.Exists(stfConfigurationFile))
            {
                KernelLogger.LogInfo($"StfConfiguration file not found - creating default [{stfConfigurationFile}]");

                if (!CreateDefaultStfConfigurationFile(stfConfigurationFile))
                {
                    KernelLogger.LogInfo($"Couldn't create Default Configuration file not found - name [{stfConfigurationFile}]");
                }
            }

            if (File.Exists(stfConfigurationFile))
            {
                KernelLogger.LogInfo($"StfConfiguration created using [{stfConfigurationFile}]");
                StfConfiguration = new StfConfiguration(stfConfigurationFile);
            }
            else
            {
                StfConfiguration = new StfConfiguration();
                KernelLogger.LogInfo($"StfConfiguration created using no file as [{stfConfigurationFile}] doesn't exist");
            }

            // need to be able to control something for plugins - like plugin path:-)
            OverlayStfConfigurationForOneSettingType(StfConfigDir, ConfigurationFileType.Machine);
        }
コード例 #2
0
        /// <summary>
        /// Set a configuration value in the configuration
        /// </summary>
        /// <param name="configKeyPath">
        /// The path the configuration key
        /// </param>
        /// <param name="value">
        /// The value to set
        /// </param>
        /// <returns>
        /// A bool indicating whether it was possible to set the configuration value
        /// </returns>
        protected bool SetConfigurationValue(string configKeyPath, string value)
        {
            bool retVal;

            try
            {
                retVal = StfConfiguration.SetConfigValue(configKeyPath, value);
            }
            catch (Exception ex)
            {
                KernelLogger.LogDebug("Failed to set configuration. Got exception: [{0}]", ex.Message);
                retVal = false;
            }

            return(retVal);
        }
コード例 #3
0
        /// <summary>
        /// The dispose.
        /// </summary>
        /// <param name="disposing">
        /// The disposing.
        /// </param>
        protected virtual void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    if (KernelLogger != null)
                    {
                        KernelLogger.LogDebug("Closing log files and disposing container");
                        KernelLogger.CloseLogFile();
                    }

                    PluginLoader?.Dispose();
                }

                disposed = true;
            }
        }
コード例 #4
0
        /// <summary>
        /// The overlay stf configuration for one setting type.
        /// </summary>
        /// <param name="directoryName">
        /// The directory name.
        /// </param>
        /// <param name="configurationFileType">
        /// The configuration file type.
        /// </param>
        /// <exception cref="ArgumentOutOfRangeException">
        /// Exception if configuration file type is unrecognized
        /// </exception>
        private void OverlayStfConfigurationForOneSettingType(string directoryName, ConfigurationFileType configurationFileType)
        {
            string configFilename;

            if (!Directory.Exists(directoryName))
            {
                return;
            }

            switch (configurationFileType)
            {
            case ConfigurationFileType.Machine:
                configFilename = "StfConfiguration_Machine.xml";
                break;

            case ConfigurationFileType.User:
                configFilename = "StfConfiguration_User.xml";
                break;

            case ConfigurationFileType.TestCase:
                configFilename = "StfConfiguration_TestCase.xml";
                break;

            case ConfigurationFileType.TestSuite:
                configFilename = "StfConfiguration_TestSuite.xml";
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(configurationFileType), configurationFileType, null);
            }

            var fileLocation = Path.Combine(directoryName, configFilename);

            if (!File.Exists(fileLocation))
            {
                KernelLogger.LogInternal($"Skipping Configuration file [{fileLocation}]: It does not exist, so not overlaying");
                return;
            }

            KernelLogger.LogInternal($"Applying configuration found at [{fileLocation}]");

            StfConfiguration.OverLay(fileLocation);
        }