C# .net或如何在xml中为构造函数参数指定组件属性?
我不知道如何将Component属性传递给构造函数参数C# .net或如何在xml中为构造函数参数指定组件属性?,c#,castle-windsor,C#,Castle Windsor,我不知道如何将Component属性传递给构造函数参数 <component id="NotificationCenterManager" service="Advise.Notification.INotificationCenterManager, Xsquare" type="Advise.Notification.NotificationCenterManager, Xsquare">
<component id="NotificationCenterManager"
service="Advise.Notification.INotificationCenterManager, Xsquare"
type="Advise.Notification.NotificationCenterManager, Xsquare">
</component>
<component id="JobProcessorConfigurationSender"
service="Advise.Core.JobProcessor.IJobProcessorConfigurationSender, Advise.Core"
type="Advise.JobProcessorManagement.JobProcessorConfigurationSender, Xsquare">
<parameters>
<notificationCenterUri>${NotificationCenterManager.NotificationCenterUri}
</notificationCenterUri>
</parameters>
</component>
其中NotificationCenterUri是接口INotificationCenterManager的属性。
目前${NotificationCenterManager.NotificationCenterUri}被视为一个文本
有什么想法吗
谢谢温莎没有提供开箱即用的服务。您必须编写一个程序来实现它。但是,我不建议这样做:这样做会使JobProcessorConfigurationSender隐式依赖于NotificationCenterManager,因为它不在JobProcessorConfigurationSender的源代码中
取而代之的是,考虑将这个URI作为A,然后在NoTimeCtCurnMeCurnor和JoopPrimeCurraseServer的组件配置中引用它。问题在于URI是动态的,并且依赖于machinename。你还有其他建议吗?Thanks@Pierre-Louis:如果您必须使用XML进行此操作,您可以创建一个提供此信息的IUriProvider服务,然后在NotificationCenterManager和JobProcessorConfigurationSender@Pierre-Louis:另一个选择是编写ISubDependencyResolver或IContributeComponentModelConstruction,我想我会这么做。谢谢