System.Data.SqlClient.SqlConnection.SqlConnection.ParseDataSource C# (CSharp) Метод

ParseDataSource() приватный Метод

private ParseDataSource ( string theDataSource, int &thePort, string &theServerName ) : bool
theDataSource string
thePort int
theServerName string
Результат bool
		private bool ParseDataSource (string theDataSource, out int thePort, out string theServerName)
		{
			theServerName = string.Empty;
			string theInstanceName = string.Empty;
	
			if (theDataSource == null)
				throw new ArgumentException("Format of initialization string does not conform to specifications");

			thePort = DEFAULT_PORT; // default TCP port for SQL Server
			bool success = true;

			int idx = 0;
			if ((idx = theDataSource.IndexOf (',')) > -1) {
				theServerName = theDataSource.Substring (0, idx);
				string p = theDataSource.Substring (idx + 1);
				thePort = Int32.Parse (p);
			} else if ((idx = theDataSource.IndexOf ('\\')) > -1) {
				theServerName = theDataSource.Substring (0, idx);
				theInstanceName = theDataSource.Substring (idx + 1);

				// do port discovery via UDP port 1434
				port = DiscoverTcpPortViaSqlMonitor (theServerName, theInstanceName);
				if (port == -1)
					success = false;
			} else
				theServerName = theDataSource;

			if (theServerName.Length == 0 || theServerName == "(local)" || theServerName == ".")
				theServerName = "localhost";

			if ((idx = theServerName.IndexOf ("tcp:")) > -1)
				theServerName = theServerName.Substring (idx + 4);

			return success;
		}