Access .NET class members
- Last Updated: April 24, 2023
- 4 minute read
- OpenEdge
- Version 12.2
- Documentation
ABL supports access to public or protected members of a .NET class instance using much the same syntax for accessing public or protected members of an ABL class instance. This includes support for using built-in ABL data types that automatically map to specified .NET data types, for example, to get and set .NET property values or to pass .NET method parameters. For more information on data type mapping, see Use .NET data types in ABL.
So, you can access the following members of a .NET class instance in exactly the same way as you access them for an ABL class instance:
- .NET constructors — Invoke a .NET class constructor by instantiating a .NET class exactly like an ABL class using the NEW function (classes). From the constructor of an ABL-derived .NET class, you can also access a constructor of the immediate super class using the SUPER statement. For more information, see Instantiate and manage .NET class instances, and Specify .NET constructor and method parameters.
- .NET fields — Equivalent to ABL data members, read or write the values of .NET fields of a class using class-based data member access, as described in ABL Reference.
- .NET methods — Invoke .NET methods of a class using class-based method calls, as described in ABL Reference. Also, see Specify .NET constructor and method parameters.
- .NET properties — Set or get the values of .NET properties of a class using class-based property access, as described in ABL Reference. You can also access .NET properties dynamically using Access .NET indexed properties dynamically.
- .NET object events — Like ABL classes, .NET classes can define, publish, and handle events. .NET applications handle events by subscribing .NET methods as event handlers. ABL applications can handle .NET events by subscribing ABL methods and internal procedures as event handlers. These ABL event handlers respond to published .NET events in a manner similar to .NET event handlers in .NET applications. For more information, see Handle .NET events.
.) instead of a colon (:),
as in ABL.ABL allows you to use native syntax to access class members in support of certain .NET features not supported in native ABL applications. These include:
- .NET interface members — .NET supports types of interface members that ABL interfaces do not support. For more information on accessing these interface members in ABL, see the .
- .NET enumeration types — Enumerations are special .NET classes that can represent a particular enumerated subset of values of a given .NET data type. Each value of that subset is represented as a member of a given enumeration type. For more information on enumeration types and how to use them in ABL, see Access and use .NET enumeration types.
ABL also provides extended syntax to access .NET class member features that are currently not supported for ABL class members or that require additional syntax to access them in the .NET context. The following sections thus describe the extended syntax for:
- Static members of a .NET class — .NET supports static class members, which are accessible in ABL only on the class type exactly like static members of ABL classes. The only difference for .NET static members in ABL is the additional syntax for accessing .NET inner class types (see Reference .NET class and interface types). For general information on accessing static class members in ABL, see Develop Object-oriented ABL Applications. For more information on accessing .NET static class members in ABL, see Access static members of a .NET class.
-
Explicit mappings to .NET data types — In many
cases, wherever a given .NET data type maps to an ABL primitive
type, you can use the corresponding ABL primitive type to exchange
data with the .NET type. However, some usage requires that
you explicitly indicate the .NET data type that you intend
to use. For example:
- You must use appropriate mappings between ABL and .NET parameter options to pass ABL data to overloaded .NET constructor and method parameters. ABL extends its parameter-passing syntax to specify explicit mappings between ABL primitive types and the corresponding .NET mapped data types of parameters. For more information on how and why ABL supports these mappings, see Specify .NET constructor and method parameters.
- You must use explicit mappings for .NET mapped data types when you override .NET methods or .NET abstract properties in an ABL-derived .NET class. For more information, see Derive .NET classes in ABL.
- You must use explicit mappings for .NET mapped data types when you reference the constructed type name of a .NET generic type. For more information, see Reference .NET generic types.
- .NET indexed properties and collections — .NET supports properties that can provide access to a keyed group of values. .NET commonly uses these indexed properties to support object collections. For more information on using both .NET indexed properties and collections in ABL, see Access .NET indexed properties and collections.