Model framework

1.Model framework

    A model framework can be used to define complex models that are extended by third parties. For example, XWorker's SWT and WEB models, third parties can also register their own controls, after registration, users can easily use new controls. Model frameworks are widely used in XWorker.

2.Defining framework

2.1.Framework is the relationship between models

    Framework is the relationship between models. For example, if a container control of SWT can add various controls, the parent-child relationship will be formed between container control and control that can be added. Therefore, to define a model framework, we first need to determine the relationship between the models.

    The common model relationship in XWorker is child, that is, a model can be called a sub-node of the relevant model. The relationships between models can be customized, and documents, wizards, templates, and so on are common.

2.2.Agreement of action

    Defining a framework often requires agreeing on the behavior between models. For example, XWorker's SWT model specifies that the control model has a create method and the action model has a run method.

2.3.Regist model

     The way to write a model framework is to create a master model first. Then the related model is registered on the master model. For example, first create a control set model of SWT, and then register specific controls on the control set model.

     To register the model, you can use MetaThing to edit it.

    Under MetaThing's form, we set up related items to register the model.

3.Use framework

    There are many ways to use model frameworks. The following is an example of an extended framework model.

3.1.Inheritance Framework Model

    Actions in the dynamic model are equivalent to functions and methods, and there are many functions and methods. By defining the action framework, we can integrate all kinds of actions and inherit the action framework in practical use.

    For example, the action sub-nodes in the xworker.lang.MetaDescriptor3 model in XWorker are used to define the behavior of the model, where the action sub-nodes inherit the action framework model.

3.2.Using Framework Model

     After inheriting the action framework model, you can use the sub-models contained in the framework, such as the action model of the xworker.lang.MetaDescriptor3 model above to write the behavior of the model.

    As you can see, there are many action models to choose from, which is one of the functions of the framework model.

 

Copyright ©  2007-2019 XWorker.org  版权所有  沪ICP备08000575号