views:

234

answers:

1

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?

+3  A: 

With the EventWiring Facility you can use the configuration to connect component's methods (subscribers) to component's events (publishers).

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>

Watson
I had an itch like it was time to check this post again. Awesome, thanks a lot.
George Mauer