GetParameterWithSubstitution() 공개 메소드

Similar to the regular GetParameter method, except it will substitute environment variables in the values if present.
public GetParameterWithSubstitution ( string component, string parameter, bool tolerant ) : string
component string The component or section of the config file, used to /// locate the parameter.
parameter string The name of the config parameter.
tolerant bool If true, this method logs warnings for unmatched environment /// variables. If false, it throws exceptions.
리턴 string
예제 #1
0
 /// <summary>
 /// Populates the descriptor's values from a config file.
 /// </summary>
 /// <param name="config">Config to get params from.</param>
 /// <param name="component">Section of the config XML to look in for db params.</param>
 /// <param name="decryptionDelegate">Delegate to call to decrypt password fields.
 ///                                  May be null if passwords are in plain text.</param>
 public CsvDescriptor(Config config, string component,
     ConnectionInfoDecryptionDelegate decryptionDelegate)
     : this(CsvConnectionType.Unknown,
            config.GetParameterWithSubstitution(component, "Path", true),
            null, null,
            config.ParameterExists(component, "OutputQuoteLevel")
                ? (CsvQuoteLevel) Enum.Parse(typeof (CsvQuoteLevel),config.GetParameter(component, "OutputQuoteLevel"))
                : CsvQuoteLevel.QuoteStrings)
 {
 }
예제 #2
0
        /// <summary>
        /// This constructor reads all the appropriate values from our standard config file
        /// in the normal format.
        /// </summary>
        /// <param name="config">Config to get params from.</param>
        /// <param name="component">Section of the config XML to look in for db params.</param>
        /// <param name="decryptionDelegate">Delegate to call to decrypt password fields.
        ///                                  May be null if passwords are in plain text.</param>
        public SQLiteDescriptor(Config config, string component,
            ConnectionInfoDecryptionDelegate decryptionDelegate)
        {
            SQLiteConnectionStringBuilder builder = new SQLiteConnectionStringBuilder();

            builder.Pooling = false;
            _usePooling = false;

            builder.DataSource = _databasePath = config.GetParameterWithSubstitution(component, "Database", true);

            // We don't currently support passwords, so the clean conn str is the same
            // as the real one.
            _cleanConnStr = builder.ToString();
            _connectionStr = builder.ToString();
        }
예제 #3
0
        /// <summary>
        /// This constructor reads all the appropriate values from our standard config file
        /// in the normal format.
        /// </summary>
        /// <param name="config">Config to get params from.</param>
        /// <param name="component">Section of the config XML to look in for db params.</param>
        /// <param name="decryptionDelegate">Delegate to call to decrypt password fields.
        ///                                  May be null if passwords are in plain text.</param>
        public FirebirdDescriptor(Config config, string component,
            ConnectionInfoDecryptionDelegate decryptionDelegate)
        {
            FbConnectionStringBuilder builder = new FbConnectionStringBuilder();
            Server = config.GetParameter(component, "Server", null);
            if (StringHelper.IsNonBlank(Server))
            {
                builder.DataSource = Server;
            }
            else
            {
                builder.ServerType = FbServerType.Embedded;
                // For the embedded server, we want to disable pooling so we don't wind up locking
                // the file indefinitely.
                builder.Pooling = false;
                _usePooling = false;
            }
            builder.Database = Database = config.GetParameterWithSubstitution(component, "Database", true);
            builder.UserID = User = config.GetParameter(component, "User", null);

            // First make it without a password.
            _cleanConnStr = builder.ToString();
            // Now with the password for the real one.
            Password = GetDecryptedConfigParameter(config, component, "Password", decryptionDelegate);
            builder.Password = Password;
            _connectionStr = builder.ToString();
        }
예제 #4
0
 /// <summary>
 /// This constructor reads all the appropriate values from a config file.
 /// </summary>
 /// <param name="config">Config to get params from.</param>
 /// <param name="component">Section of the config XML to look in for db params.</param>
 /// <param name="decryptionDelegate">Delegate to call to decrypt password fields.
 ///                                  May be null if passwords are in plain text.</param>
 public OleDbDescriptor(Config config, string component,
     ConnectionInfoDecryptionDelegate decryptionDelegate)
     : this(GetTypeFromConfig(config, component),
            config.GetParameter(component, "Provider", null),
            config.GetParameter(component, "Server", null),
            config.GetParameterWithSubstitution(component, "Database", true, null),
            config.GetParameter(component, "User", null),
            GetDecryptedConfigParameter(config, component, "Password", decryptionDelegate),
            config.GetParameterAsInt(component, "Connect_Timeout", null))
 {
 }