I have something like this:
我有这样的事情:
public interface IDeviceMonitor {
int DeviceId { get; }
event DeviceUpdatedHandler NewValueRecieved;
void Start();
void Stop();
}
public class DeviceInactivityDetector {
...
public virtual void DeviceUpdated(IDeviceMonitor device, DeviceUpdatedArgs args) {
....
}
}
currently, in my application startup file I do
目前,在我的应用程序启动文件中
var dm = IoC.Container.Resolve<IDeviceMonitor>();
var did = IoC.Container.Resolve<DeviceInactivityDetector>();
dm.NewValueRecieved += new DeviceUpdatedHandler(did.DeviceUpdated);
I imagine it is possible to do this wiring with my castle configuration file via xml. But how?
我想可以通过xml与我的城堡配置文件进行这种连接。但是怎么样?
1 个解决方案
#1
4
With the EventWiring Facility you can use the configuration to connect component's methods (subscribers) to component's events (publishers).
使用EventWiring Facility,您可以使用配置将组件的方法(订户)连接到组件的事件(发布者)。
http://www.castleproject.org/container/facilities/v1rc3/eventwiring/index.html
<configuration>
<facilities>
<facility
id="event.wiring"
type="Castle.Facilities.EventWiring.EventWiringFacility, Castle.MicroKernel" />
</facilities>
<components>
<component
id="DeviceInactivityDetector"
type=" . . ." />
<component
id="IDeviceMonitor"
type=". . ." >
<subscribers>
<subscriber id="DeviceInactivityDetector" event="NewValueRecieved" handler="DeviceUpdated"/>
</subscribers>
</component>
</components>
#1
4
With the EventWiring Facility you can use the configuration to connect component's methods (subscribers) to component's events (publishers).
使用EventWiring Facility,您可以使用配置将组件的方法(订户)连接到组件的事件(发布者)。
http://www.castleproject.org/container/facilities/v1rc3/eventwiring/index.html
<configuration>
<facilities>
<facility
id="event.wiring"
type="Castle.Facilities.EventWiring.EventWiringFacility, Castle.MicroKernel" />
</facilities>
<components>
<component
id="DeviceInactivityDetector"
type=" . . ." />
<component
id="IDeviceMonitor"
type=". . ." >
<subscribers>
<subscriber id="DeviceInactivityDetector" event="NewValueRecieved" handler="DeviceUpdated"/>
</subscribers>
</component>
</components>