我在我的项目中定义了以下接口:
public interface IInteractiveValidator
{
Func<string, bool> QuestionDelegate { get; set; }
}
如何在使用 StructureMapQusetionDelegate
实现以下代码的所有类中设置属性?IInteractiveValidator
message => MessageBox.Show(s, "Question", MessageBoxButtons.YesNo) == DialogResult.Yes;
更新(问题解决)
container.Configure(r => r.For<IInteractiveValidator>()
.OnCreationForAll("", validator =>
{
validator.QuestionDelegate = message => MessageBox
.Show(s, "Question", MessageBoxButtons.YesNo) == DialogResult.Yes;
}));