Exemple #1
0
        /// <summary>
        /// Get connection property based on DataSourceAttribute. If its in config file then read it from config.
        /// </summary>
        /// <param name="dataSourceAttribute">The dataSourceAttribute.</param>
        /// <param name="providerNameInvariant">The provider name.</param>
        /// <param name="connectionString">The connection string.</param>
        /// <param name="tableName">The table name.</param>
        /// <param name="dataAccessMethod">The data access method.</param>
        private void GetConnectionProperties(UTF.DataSourceAttribute dataSourceAttribute, out string providerNameInvariant, out string connectionString, out string tableName, out UTF.DataAccessMethod dataAccessMethod)
        {
            if (string.IsNullOrEmpty(dataSourceAttribute.DataSourceSettingName) == false)
            {
                UTF.DataSourceElement elem = UTF.TestConfiguration.ConfigurationSection.DataSources[dataSourceAttribute.DataSourceSettingName];
                if (elem == null)
                {
                    throw new Exception(string.Format(CultureInfo.CurrentCulture, Resource.UTA_DataSourceConfigurationSectionMissing, dataSourceAttribute.DataSourceSettingName));
                }

                providerNameInvariant = ConfigurationManager.ConnectionStrings[elem.ConnectionString].ProviderName;
                connectionString      = ConfigurationManager.ConnectionStrings[elem.ConnectionString].ConnectionString;
                tableName             = elem.DataTableName;
                dataAccessMethod      = (UTF.DataAccessMethod)Enum.Parse(typeof(UTF.DataAccessMethod), elem.DataAccessMethod);
            }
            else
            {
                providerNameInvariant = dataSourceAttribute.ProviderInvariantName;
                connectionString      = dataSourceAttribute.ConnectionString;
                tableName             = dataSourceAttribute.TableName;
                dataAccessMethod      = dataSourceAttribute.DataAccessMethod;
            }
        }
Exemple #2
0
 /// <summary>
 ///     Initializes a new instance of the DataSourceAttribute class.
 ///     This instance will be initialized with a data provider, connection string, data table and data access method to access the data source.
 /// </summary>
 /// <param name="providerInvariantName">Invariant data provider name, such as System.Data.SqlClient .</param>
 /// <param name="connectionString">
 ///     Data provider specific connection string.
 ///     WARNING: The connection string can contain sensitive data (for example, a password).
 ///     The connection string is stored in plain text in source code and in the compiled assembly.
 ///     Restrict access to the source code and assembly to protect this sensitive information.</param>
 /// <param name="tableName">The name of the data table.</param>
 /// <param name="dataAccessMethod">Specifies the order to access data.</param>
 public DynamicDatasourceAttribute(string providerInvariantName, string connectionString, string tableName, DataAccessMethod dataAccessMethod)
 {
     _dataSource = new DataSourceAttribute(providerInvariantName, connectionString, tableName, dataAccessMethod);
 }
Exemple #3
0
 /// <summary>
 ///     Initializes a new instance of the DynamicDatasourceAttribute class.
 ///     This instance will be initialized with a data provider and connection string associated with the setting name.
 /// </summary>
 /// <param name="dataSourceSettingName">The name of a data source found in the <microsoft.visualstudio.qualitytools> section in the ConfigurationManager configuration file.</param>
 public DynamicDatasourceAttribute(string dataSourceSettingName)
 {
     _dataSource = ConfigurationManager.GetDataSource(dataSourceSettingName);
 }