在一个旧的项目覆盖的公共属性,我们使用的是第三方组件,有一些硬编码信息的属性的类:派生类
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