Npgsql.NpgsqlConnectionStringBuilder.SetValue C# (CSharp) Method

SetValue() private method

The function will modify private member only, not base[key].
private SetValue ( Keywords keyword, object value ) : void
keyword Keywords
value object
return void
		private void SetValue(Keywords keyword, object value)

		{
			string key_name = GetKeyName(keyword);

			try

			{
				switch (keyword)

				{
					case Keywords.Host:

						this._host = Convert.ToString(value);

						break;

					case Keywords.Port:

						this._port = Convert.ToInt32(value);

						break;

					case Keywords.Protocol:

						this._protocol = ToProtocolVersion(value);

						break;

					case Keywords.Database:

						this._database = Convert.ToString(value);

						break;

					case Keywords.UserName:

						this._username = Convert.ToString(value);

						break;

					case Keywords.Password:

						this._password = Convert.ToString(value);

						break;

					case Keywords.SSL:

						this._ssl = ToBoolean(value);

						break;

					case Keywords.SslMode:

						this._sslmode = ToSslMode(value);

						break;

#pragma warning disable 618
					case Keywords.Encoding:
						break;
#pragma warning restore 618

					case Keywords.Timeout:

						this._timeout = ToInt32(value, 0, TIMEOUT_LIMIT, key_name);

						break;

					case Keywords.SearchPath:

						this._searchpath = Convert.ToString(value);

						break;

					case Keywords.Pooling:
					    
						this._pooling = ToBoolean(value);
						
						break;

					case Keywords.ConnectionLifeTime:

						this._connection_life_time = Convert.ToInt32(value);

						break;

					case Keywords.MinPoolSize:

						this._min_pool_size = (MaxPoolSize > 0) ? ToInt32(value, 0, MaxPoolSize, key_name) : Convert.ToInt32(value);

						break;

					case Keywords.MaxPoolSize:

						this._max_pool_size = ToInt32(value, 0, POOL_SIZE_LIMIT, key_name);

						break;

					case Keywords.SyncNotification:

						this._sync_notification = ToBoolean(value);

						break;

					case Keywords.CommandTimeout:

						this._command_timeout = Convert.ToInt32(value);

						break;

					case Keywords.Enlist:

						this._enlist = ToBoolean(value);

						break;

					case Keywords.PreloadReader:

						this._preloadReader = ToBoolean(value);

						break;

					case Keywords.UseExtendedTypes:

						this._useExtendedTypes = ToBoolean(value);

                        break;
                    case Keywords.IntegratedSecurity:
                        this._integrated_security = ToIntegratedSecurity(value);
                        break;
				}
			}

			catch (InvalidCastException exception)

			{
				string exception_template = string.Empty;

				switch (keyword)

				{
					case Keywords.Port:

					case Keywords.Timeout:

					case Keywords.ConnectionLifeTime:

					case Keywords.MinPoolSize:

					case Keywords.MaxPoolSize:

					case Keywords.CommandTimeout:

						exception_template = resman.GetString("Exception_InvalidIntegerKeyVal");

						break;

					case Keywords.SSL:

					case Keywords.Pooling:

					case Keywords.SyncNotification:

						exception_template = resman.GetString("Exception_InvalidBooleanKeyVal");

						break;

					case Keywords.Protocol:

						exception_template = resman.GetString("Exception_InvalidProtocolVersionKeyVal");

						break;
				}

				if (!string.IsNullOrEmpty(exception_template))

				{
					throw new ArgumentException(string.Format(exception_template, key_name), key_name, exception);
				}

				throw;
			}
		}

Same methods

NpgsqlConnectionStringBuilder::SetValue ( string keyword, object value ) : void