.NET Data: Conversion Rules
About this task
- Properties and methods.
- Events.
- Complex data types.
- Strategies for parameter types that cannot be converted.
Properties and Methods
If a custom or third-party .NET control is one of the supported .NET control types, any public property or method defined in the control class will be exposed if the data type of the property or the type of each parameter of the method is one of the following types:
Type | Description |
---|---|
Primitive | Including integral and floating numeric |
COM recognizable |
Including:
|
COM visible |
Such as:
|
NET generic list |
|
DataTable and DataView classes |
|
Windows Forms Font |
|
- The property or method in the exposed COM interface will have the corresponding COM types converted from the original .NET types.
- If a property or method does not meet the above condition, it will be ignored in the component building process and will not be available in the component COM interface.
Events
All the public events defined in the control class are exposed as COM connection point handlers, according to the following rules:
Procedure
- If all the parameter types of a .NET event delegate are convertible according to the conditions listed in the Properties and Methods section, the .NET event delegate will be converted to a COM event handler with the same number of parameters of the corresponding COM types.
-
Some common .NET delegate types are converted to specifically defined COM event handlers.
These include the:
- Mouse events.
- WPF MouseEventHandler
- MouseButtonEventHandler
- MouseWheelEventHandler
- WinForms MouseEventHandler delegates
- Key events
- WPF KeyEventHandler
- KeyboardEventHandler
- WinForms KeyEventHandler
- KeyPressEventHandler delegates
- Selection events
- SelectionChangedEventHandler
- EventHandler<SelectionChangedEventArgs> delegates.
-
The converted COM mouse event handlers are defined to have three parameters:
- Mouse button state.
- X and Y positions
Refer to the Win32 documents for the definitions of the mouse button state.
-
The COM key event handlers are defined to have two parameters
- Key state
- Key code
Refer to the Win32 documents for the definitions of the key state.
-
The converted COM selection event handler has two parameters of the COM Variant type with an array subtype:
- AddedItems, for items newly added to the selected items collection.
- RemovedItems, for items newly removed from the selected items collection.
Note: To avoid array indexing problems (the items arrays might be empty), check with the VBA function
UBound
. -
All other delegates that follow the .NET convention (two parameters: sender of the Object type and e of an EventArgs derived type) are converted to a COM handler of two parameters of the String type.
Complex Data Types
The data conversion module supports passing complex data types such as arrays (lists) and data tables. The supported .NET types are exposed as common COM types or specific interfaces and types implemented by the conversion module. The supported COM types may be passed to or returned from the methods and properties of .NET controls, to which, as a result of data conversion, these data types appear as the corresponding .NET types.
-
DataTable
,DataView
(both of System.Data) andIEnumerable
(of System.Collection). - These types appear as
ADODB Recordset
and are used to pass data tables with columns and rows.
IEnumerable
is converted to Recordset because many .NET controls use the IEnumerable interface to pass DataTable objects.- Add the Microsoft ActiveX Data Objects Library (2.7 or higher) reference when scripting with these date types.
Refer to ADODB documents for the usage of the Recordset interface.
-
List<
short>
,List<
int>
,List<
float>
,List<
double>
, andList<
string>
(all of System.Collections.Generic).
These types, implemented in the data conversion module, appear as:
- ShortList
- IntList
- FloatList
- DoubleList
- StringList
Add the
GEIP_Orion_Dataconversion
reference when scripting with these date types.The ShortList list implements the following interface:
interface IShortList : IDispatch { [id(0x60020000), propget] HRESULT Count([out, retval] long* pRetVal); [id(0x60020001)] HRESULT Add([in] short item); [id(0x60020002)] HRESULT Clear(); [id(00000000), propget] HRESULT item( [in] long index, [out, retval] short* pRetVal); [id(00000000), propput] HRESULT item( [in] long index, [in] short pRetVal); [id(0x60020005)] HRESULT Insert( [in] long index, [in] short item); [id(0x60020006)] HRESULT RemoveAt([in] long index); };
All the rest implement basically the same interface, but with different data types (
long
forIntList
, etc.) for the item parameter.-
ArrayList
(of System.Collections).
This displays as
ObjectList
, which implements the following interface:interface IObjectList : IDispatch { [id(0x60020000), propget] HRESULT Count([out, retval] long* pRetVal); [id(0x60020001)] HRESULT Add( [in] VARIANT item, [out, retval] long* pRetVal); [id(0x60020002)] HRESULT Clear(); [id(00000000), propget] HRESULT item( [in] long index, [out, retval] VARIANT* pRetVal); [id(00000000), propputref] HRESULT item( [in] long index, [in] VARIANT pRetVal); [id(0x60020005)] HRESULT Insert( [in] long index, [in] VARIANT item); [id(0x60020006)] HRESULT RemoveAt([in] long index); };
As the item type here is
VARIANT
, this list can pass any convertible types supported by the data conversion module.For example, list objects can be added to an
ObjectList
as list items, resulting a multi- dimensional array.Add the
GEIP_Orion_Dataconversion
reference when scripting with this date type.Strategies for Parameter Types that Cannot Be Converted
Most commonly used parameter types are converted, so CIMPLICITY screens host and also communicate with the .NET controls through primitive data types and converted parameter types.
However, there will be parameter types that cannot be converted and thus ignored by the current release because the authors of custom .NET controls may use any Framework types and create and use their own types.
In order to avoid the essential properties, methods and events of a .NET control not being exposed, the control author may do the following.
- Rewrite a desired property using the convertible types listed above.
- Separate a desired property into multiple properties of the convertible type.
- Rewrite a method with the convertible types or with more parameters so that each parameter can be converted.
- Define a new event type (delegate) with all parameters convertible and reroute the original event with the new delegate.
-