在一箇舊的項目覆蓋的公共屬性,我們使用的是第三方組件,有一些硬編碼信息的屬性的類:派生類
public string ConnectionString
{
get
{
string[] fullDbName = new string[5];
fullDbName[0] = "Data Source=";
fullDbName[1] = this.dbServer;
fullDbName[2] = ";Initial Catalog=";
fullDbName[3] = this.FullDbName;
fullDbName[4] = ";Integrated Security=SSPI;Pooling=false";
return string.Concat(fullDbName);
}
}
我需要能夠構建連接串我的自我。所以,我試圖讓一個派生類隱藏了原來的屬性,但它似乎不工作:
public class SqlServerRestorerExstension : SQLServerRestorer
{
public SqlServerRestorerExstension(string dbServer, string dbName, string dbFilePath, string dbDataFileName, string dbLogFileName, bool detachOnFixtureTearDown, string connectionstring) : base(dbServer, dbName, dbFilePath, dbDataFileName, dbLogFileName, detachOnFixtureTearDown)
{
ConnectionString = connectionstring;
}
public string ConnectionString { get; private set; }
}
是否有可能做任何的方式實現這一目標時,我沒有存取權限的第三方碼?
SQLServerRestorer是否實現了其中聲明瞭ConnectionString的任何接口? – 2012-02-07 15:37:48
不,ConnectionString屬性被聲明爲類SQLServerRestorer上的公共屬性。 – peterbf 2012-02-14 07:11:28