System.Data.SqlClient.SqlConnection.SqlConnection.SetProperties C# (CSharp) Méthode

SetProperties() private méthode

private SetProperties ( string name, string value ) : void
name string
value string
Résultat void
		private void SetProperties (string name , string value)
		{
			switch (name) {
			case "app" :
			case "application name" :
				parms.ApplicationName = value;
				break;
			case "attachdbfilename" :
			case "extended properties" :
			case "initial file name" :
				parms.AttachDBFileName = value;
				break;
			case "timeout" :
			case "connect timeout" :
			case "connection timeout" :
				int tmpTimeout = ConvertToInt32 ("connect timeout", value,
					DEFAULT_CONNECTIONTIMEOUT);
				if (tmpTimeout < 0)
					throw new ArgumentException ("Invalid 'connect timeout'. Must be an integer >=0 ");
				else 
					connectionTimeout = tmpTimeout;
				break;
			case "connection lifetime" :
				break;
			case "connection reset" :
				connectionReset = ConvertToBoolean ("connection reset", value, true);
				break;
			case "language" :
			case "current language" :
				parms.Language = value;
				break;
			case "data source" :
			case "server" :
			case "address" :
			case "addr" :
			case "network address" :
				dataSource = value;
				break;
			case "encrypt":
				if (ConvertToBoolean (name, value, false))
					throw new NotImplementedException("SSL encryption for"
						+ " data sent between client and server is not"
						+ " implemented.");
				break;
			case "enlist" :
				if (!ConvertToBoolean (name, value, true))
					throw new NotImplementedException("Disabling the automatic"
						+ " enlistment of connections in the thread's current"
						+ " transaction context is not implemented.");
				break;
			case "initial catalog" :
			case "database" :
				parms.Database = value;
				break;
			case "integrated security" :
			case "trusted_connection" :
				parms.DomainLogin = ConvertIntegratedSecurity(value);
				break;
			case "max pool size" :
				int tmpMaxPoolSize = ConvertToInt32 (name, value, DEFAULT_MAXPOOLSIZE);
				if (tmpMaxPoolSize < MIN_MAXPOOLSIZE)
					throw new ArgumentException (string.Format (CultureInfo.InvariantCulture,
						"Invalid '{0}'. The value must be greater than {1}.",
						name, MIN_MAXPOOLSIZE));
				else
					maxPoolSize = tmpMaxPoolSize;
				break;
			case "min pool size" :
				int tmpMinPoolSize = ConvertToInt32 (name, value, DEFAULT_MINPOOLSIZE);
				if (tmpMinPoolSize < 0)
					throw new ArgumentException ("Invalid 'min pool size'. Must be a integer >= 0");
				else
					minPoolSize = tmpMinPoolSize;
				break;
#if NET_2_0
			case "multipleactiveresultsets":
				// FIXME: not implemented
				ConvertToBoolean (name, value, false);
				break;
			case "asynchronous processing" :
			case "async" :
				async = ConvertToBoolean (name, value, false);
				break;
#endif
			case "net" :
			case "network" :
			case "network library" :
				if (!value.ToUpper ().Equals ("DBMSSOCN"))
					throw new ArgumentException ("Unsupported network library.");
				break;
			case "packet size" :
				int tmpPacketSize = ConvertToInt32 (name, value, DEFAULT_PACKETSIZE);
				if (tmpPacketSize < MIN_PACKETSIZE || tmpPacketSize > MAX_PACKETSIZE)
					throw new ArgumentException (string.Format (CultureInfo.InvariantCulture,
						"Invalid 'Packet Size'. The value must be between {0} and {1}.",
						MIN_PACKETSIZE, MAX_PACKETSIZE));
				else
					packetSize = tmpPacketSize;
				break;
			case "password" :
			case "pwd" :
				parms.Password = value;
				break;
			case "persistsecurityinfo" :
			case "persist security info" :
				// FIXME : not implemented
				// throw new NotImplementedException ();
				break;
			case "pooling" :
				pooling = ConvertToBoolean (name, value, true);
				break;
			case "uid" :
			case "user" :
			case "user id" :
				parms.User = value;
				break;
			case "wsid" :
			case "workstation id" :
				parms.Hostname = value;
				break;
#if NET_2_0
			case "user instance":
				userInstance = ConvertToBoolean (name, value, false);
				break;
#endif
			default :
				throw new ArgumentException("Keyword not supported : '" + name + "'.");
			}
		}