Yes, there's the System.Data.Common.DbConnectionStringBuilder
class.
The DbConnectionStringBuilder class
provides the base class from which the
strongly typed connection string
builders (SqlConnectionStringBuilder,
OleDbConnectionStringBuilder, and so
on) derive. The connection string
builders let developers
programmatically create syntactically
correct connection strings, and parse
and rebuild existing connection
strings.
The subclasses of interest are:
System.Data.EntityClient.EntityConnectionStringBuilder
System.Data.Odbc.OdbcConnectionStringBuilder
System.Data.OleDb.OleDbConnectionStringBuilder
System.Data.OracleClient.OracleConnectionStringBuilder
System.Data.SqlClient.SqlConnectionStringBuilder
For example, to "peek out the Data Source" from a SQL-server connection string, you can do:
var builder = new SqlConnectionStringBuilder(connectionString);
var dataSource = builder.DataSource;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…