register<T extends ComInterface> static method

void register<T extends ComInterface>(
  1. ComCompanion<T> companion
)

Registers a ComCompanion for the COM interface type T.

This enables runtime construction and identification of T.

A companion may only be registered once per type. Attempting to override a predefined companion will result in a StateError.

Example:

ComInterface.register<IExampleCom>(const IExampleComCompanion());

Implementation

static void register<T extends ComInterface>(ComCompanion<T> companion) {
  if (_predefinedCompanions.containsKey(T)) {
    throw StateError(
      'Cannot override the predefined companion for $T. '
      'Predefined companions are part of the core library.',
    );
  }
  _registeredCompanions[T] = companion;
}