0
同じプロジェクト、ProjectViewとFeatureViewに2つのクラスがあります。別のクラスのあるクラスでBindingSource
にアクセスする必要があります。私はの範囲をprivate
の代わりにinternal
にするような尖った部分があります。恥、恥ずべき。これを行うより良い方法はありますか?多分別のクラスの1つのクラスのBindingSourceにアクセス
// ProjectView.cs
public partial class ProjectView : System.Windows.Forms.UserControl {
}
// ProjectView.Designer.cs
partial class ProjectView {
// This should be private
internal System.Windows.Forms.BindingSource bsFeatures;
}
// FeatureView.cs
public partial class FeatureView : System.Windows.Forms.UserControl {
// Get ProjectView
Project currentProject = this._presenter.WorkItem.State["CurrentProject"] as Infrastructure.Interface.Aml.BusinessEntities.Project;
string key = System.String.Concat("Project", currentProject.Id);
this._presenter.WorkItem.State["CurrentProject"] = currentProject;
ProjectView view = _presenter.WorkItem.Items.Get<ProjectView>(key);
// Populate currentProject.Features with ProjectView.bsFeatures.List
currentProject.Features.Clear();
IList featureList = view.bsFeatures.List;
foreach (Feature feature in featureList)
{
currentProject.Features.Add(feature);
}
}