下面的方法怎么改写,使得更加简洁容易理解
下面是web控件的部分重写代码,有些乱,用了很多if语句,如何改写使得代码更加简洁,更加容易理解。
protected override void OnPreRender(EventArgs e)
{
if (this._controlType == "DateTime" && (BB.Get("action") == "insert" || BB.Get("action") == "copy"))
{
this.Text = DateTime.Now.ToString();
}
if (this._controlType == "UpdateDate" && BB.Get("action") == "update")
{
this.Text = DateTime.Now.ToString();
}
if (this._controlType == "InputUser" && BB.Get("action") == "insert")
{
this.Text = BB.LoginKey("Name") != null ? BB.LoginKey("Name") : String.Empty;
}
if (this._controlType == "InputUserName" && BB.Get("action") == "insert")
{
this.Text = BB.LoginKey("Name") != null ? BB.LoginKey("Name") : String.Empty;
}
if (this._controlType == "InputUserID" && (BB.Get("action") == "insert" || BB.Get("action") == "copy"))
{
this.Text = BB.LoginKey("UserID") != null ? BB.LoginKey("UserID") : String.Empty;
}
if (this._controlType == "Password")
{
this.TextMode = TextBoxMode.Password;
}
if (this._controlType == "MultiLine")
{
this.TextMode = TextBoxMode.MultiLine;
}
base.OnPreRender(e);
}
...全文


