Exemplo n.º 1
0
        /// <summary>
        /// Export the settings contained in a DataTable to multiple XML files, one per declared environment.
        /// </summary>
        /// <param name="settingsTable">DataTable containing settings values</param>
        /// <param name="properties">Properties dictionary to load</param>
        /// <param name="environmentName">Environment name to load</param>
        public void LoadSettingsFromDataTable(DataTable settingsTable, PreprocessingProperties properties, string environmentName)
        {
            int columnIndex = FindEnvironmentColumnIndex(settingsTable, environmentName);

            if (columnIndex < 0)
            {
                throw new ArgumentException(string.Format("Environment {0} was not found in settings spreadsheet", environmentName));
            }

            // Loop through the rows that contain settings and export each one to the XML file.
            for (int rowIndex = Context.FirstValueRowIndex - 1; rowIndex < settingsTable.Rows.Count; rowIndex++)
            {
                // Determine the setting name, or skip the row if there is no setting name value.
                if (settingsTable.Rows[rowIndex].IsNull(Context.SettingNameColumnIndex - 1))
                {
                    continue;
                }

                string settingName = (string)settingsTable.Rows[rowIndex][Context.SettingNameColumnIndex - 1];
                if (settingName.Trim().Length == 0)
                {
                    continue;
                }

                // Determine the setting value.
                string settingValue = GetSettingValue(settingsTable, rowIndex, columnIndex);

                properties.Add(settingName, settingValue);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Read the contents of the Settings worksheet in the specified Excel file into a DataTable.
        /// Excel files up to Excel 2000 and XML Spreadsheet 2003 files are both supported.
        /// </summary>
        /// <param name="source">Data Source</param>
        /// <param name="properties">Properties to load</param>
        /// <param name="environmentName">Name of environment to load</param>
        public void LoadSettingsFromDataSource(DataSource source, PreprocessingProperties properties, string environmentName)
        {
            DataTable dt = LoadDataTableFromDataSource(source);

            LoadSettingsFromDataTable(dt, properties, environmentName);
        }