Devart data providers intend to leverage design time aspects of development as much as possible. In this direction dotConnect for Oracle introduces new technology that allows referencing components that reside on different forms of a WinForms application. This article describes how to use the InterForm technology.
Modern applications usually implement multiform user interface and centralized data access model. However, Visual Studio provides rather inconvenient tools for design-time development of such applications. For example, it is very uncomfortable to retrieve live data in design time with single database connection and unified data access and storage module. Moreover, you have to write additional code to maintain shared connections and datasets.
The InterForm technology addresses these problems and allows you to circumvent most obstacles on the way to design time development of applications with a good architecture.
When you work in design time, it is very easy to establish cross form reference with InterForm. Select the reference property in Properties window, then click the drop down button and navigate through the tree to find the component you want to connect to.
This results in two actions. First, dotConnect for Oracle establishes reference to the selected component, so you can use it right away. Second, dotConnect for Oracle creates a virtual link that describes the referenced component symbolically. This string has three constituents: form name, component name, and, optionally, name of nested component. For example, when a DataLink object references table table1 in OracleDataSet dataSet1 on a MyForm, the virtual link string looks like MyForm.dataSet1.table1. When the referencing component is loaded in run time or design time, dotConnect for Oracle tries to resolve the virtual link. In case when referenced component cannot be found, the reference is set to null in design time, or an exception is thrown in run time. In design time, when you open the form with referenced components, the actual references are updated. When the referenced form is closed, the actual references are set back to null.
The InterForm technology can be used with properties that reference the following types:
There's important note about inheritance. Consider you have a form with a component, and this component is referenced from somewhere. Consider you have a descendant of this form. In this case the reference will still point to the ancestor component, not the descendant.
There are some requirements for InterForm to function properly. In design time, the form that contains referenced components should be always open, so that virtual links can be resolved. For the same reason, in run time the form that contains referenced components should be created before any form that references it. And there should be only one instance of the form, so that virtual links can be resolved to unique components.
The InterForm technology is supported for WinForms applications only (not available for ASP.NET and Compact Framework). The InterForm links are resolved as long as referenced form designer is created, so you have to keep it open. Likewise, if you change the name of a referenced component, and the referencing form is not open, the virtual link is not updated.
Note that in some cases, like inheritance and frame embedding, the IDE compiles ancestor (or original frame) and uses it in design time. In the compiled version the virtual link is not available, so the project may need to be recompiled to reflect most recent changes in references.
As mentioned before, the form that contains referenced components should be created before any form that references it. Hence it is not possible to establish cross-reference links like two forms referencing each other.
If you wish to use advantages of the InterForm technology, we recommend to keep all data access components on a single form, which is created before other forms in run time, and that is kept open in design time. This approach will help to build a centralized application and avoid common problems.
Below we demonstrate some examples of using the InterForm technology to solve some problems that developers encounter frequently.
Shared single connection. It is often required that a complex application with many forms and modules uses single OracleConnection that can be adjusted in single location. Using standard techniques, you would have to pass the connection in run time everywhere, which means no design time operations. But with the InterForm technology you can:
Unified data source. Sometimes application architecture requires that some set of components uses same data source. Again, this leads to inconvenient design-time operations for multiform applications. But with the InterForm technology you can:
Now when you resetup the data access components, the changes are propagated to other controls through DataLink objects automatically.
© 2002-2013 Devart. All rights reserved.