Composing boilerplate components in Dsl designer RRS feed

  • Question

  • I would like to create a component-like language much like the component examples.

    I my case, however, the components cannot be defined by the user, but have to be picked from a pre-defined list.
    Each component type will be represented by a geometry shape and a collection of ports.
    A diagram will consist of a collection of interconnected boilerplate components.

    Any ideas on how to go about defining the components in the Dsl designer ?


    Thursday, November 30, 2006 8:21 PM


  • Assuming that you fix the set of pre-defined components in the language, then you can create a component class in the dsl definition, and subclass that with the specific types if component you want to define.

    You will then need to write some custom code, a custom constructor perhaps in each type of boiler-plate component or a custom merge directive on 'ComponentModel' which is used to add a component of a specific type to a model. I'd probably go for the merge directive myself. The custom code will create all the ports etc. that go with the component.

    Then you add an element tool for each type of component.

    You probably want to make sure that the delete behavior for a component deletes all its ports when it is deleted (this will be the default if the ports are embedded in the component), and, if the ports per component are always a fixed number make it such that if you delete a port, the component gets deleted as well. Or you need to disable deletion of ports (may be possible through custom code, though I've never tried this myself).

    Hope that helps.

    Monday, December 4, 2006 3:17 PM