使用MVP的UserControl的简化示例:
界面:
namespace AuditTest.View
{
public interface IEditFindingView
{
string ITxtFindingNumber_Text { get; set; }
Image ILblFindingDate_Image { get; set; }
DateTime IDtpFindingDate_Value { get; set; }
}
}
USERCONTROL类别:
namespace AuditTest.View
{
public partial class EditFindingView : UserControl, IEditFindingView
{
public string ITxtFindingNumber_Text
{
get { return TxtFindingNumber.Text; }
set { TxtFindingNumber.Text = value; }
}
public Image ILblFindingDate_Image
{
get { return LblFindingDate.Image; }
set { LblFindingDate.Image = value; }
}
public DateTime IDtpFindingDate_Value
{
get { return DtpFindingDate.Value; }
set { DtpFindingDate.Value = value; }
}
public EditFindingView(int index)
{
InitializeComponent();
new EditFindingPres(this, index);
}
}
}
PRESENTER CLASS:
namespace AuditTest.View
{
public class EditFindingPres
{
private IEditFindingView View = null;
private AuditFindingMod Model = null;
private int FindingIndex = 0;
public EditFindingPres(IEditFindingView view, int index) : this(view, index, new AuditFindingMod())
{
}
public EditFindingPres(IEditFindingView view, int index, AuditFindingMod model)
{
try
{
if (view != null)
{
View = view;
Model = model;
FindingIndex = index;
}
else
{
throw new ArgumentNullException("IEditFindingView");
}
}
catch (Exception ex)
{
new ErrorMod().LogError(System.Reflection.MethodBase.GetCurrentMethod(), ex, true);
}
}
}
}
此UserControl是在使用系统时经常创建和处理的。我注意到,主持人没有被处分。处置完UserControl后,我该怎么做才能处置Presenter?