0 Replies Latest reply on Apr 23, 2008 1:58 PM by L_M

    Event Bubbling Custom Object not inheriting from control

      One of the new things flash flex and xaml have are ways which the event easily bubbles up to a parent that knows how to handle the event. Similar to exceptions travel up until someone catches it.

      My goal is to use the frameworks event system on custom objects. My custom objects are:
      through composition contains:
      SecurityCollection which contains many or no SecurityElements
      FileSystemCollection.cs which contains many or no FileSystemElement objects

      ect ect basically defining the following xml file with custom objects.


      <hardwareinterface type="Ethernet">
      <ethernet localipaddress="" localport="5555" remoteipaddress="" remoteport="5555" />
      <serial baudrate="115200" port="COM1" />
      <timing type="InternalClock" />
      <add id="location.scriptfiles" value="c:\\" />
      <add id="location.logfiles" value="c:\\" />
      <add id="location.configurationfiles" value="c:\\" />
      <add id="name1" value="secret1" />
      <add id="name2" value="secret2" />
      <logging EnableLogging="true" LogApplicationExceptions="true" LogInvalidMessages="true" CreateTranscript="true" />


      basically these custom objects abstract the xml details of accessing attributes, writing content out of the higher application layers.

      These custom objects hold the application configuration which contains the users options. The gui application uses these parameters across various windows forms, modal dialog boxes ect. The gui has a modal dialog that allows the user to modify these parameters during runtime.

      basically i manage: load, store, new, edit, delete of these configuration files using my custom objects.


      Where would event propagation help in custom objects like described above?
      ConfigurationSingleton.getInstance().ApplicationConfiguration.CommunicationElement.Hardwar eInterfaceElement.EthernetElement.RemoteIPAddress = System.Net.IPAddress.Parse(this.textBoxRemoteEthernetIpAddress.Text);

      The EthernetElement should propagate a changed event up to the parent ApplicationConfiguration which would persist this to the registry, db, file or whatever backend.

      currently this logic is maintained else where. I serialize the root node which compositely serializing the nested nodes and i check of the serialization is different from that in the backend … This tells me if the dom was modified. It works but i would like an event driven system.

      how should i implement bubbling using custom objects?

      3 implementation ideas:

      1) A simple way is to implement a singleton event manager: EventManager.RegisterRoutedEvent

      I like this idea but how can you tell which object is nested in who… this way the event can be stopped and discontinue propagation?

      2) If i use binders as discussed in Apress’s book: Event-Based
      Programming Taking Events to the Limit

      basically a binder connects the events between seperate objects together… although it would work for my app, I would like a more generalized approach so i can reuse the event system on future project.

      3) how does flash flex handle this..
      http://www.gamejd.com/resource/apollo_alpha1_docs/apiReference/combined/mx/utils/ObjectPro xy.html#getComplexProperty()
      >Provides a place for subclasses to override how a complex property that needs to be either proxied or daisy chained for event bubbling is managed.

      how does these systems all work....? Reflection ?

      this way i can simulate this on my own custom classes.