IMapView<K, V>.fromRawPointer constructor

IMapView<K, V>.fromRawPointer(
  1. Pointer<COMObject> ptr, {
  2. required String iterableIid,
  3. V creator(
    1. Pointer<COMObject>
    )?,
  4. K enumKeyCreator(
    1. int
    )?,
  5. V enumCreator(
    1. int
    )?,
})

Creates an instance of IMapView using the given ptr and iterableIid.

iterableIid must be the IID of the IIterable<IKeyValuePair<K, V>> interface (e.g. IID_IIterable_IKeyValuePair_String_Object).

K must be of type Guid, int, Object, String, or WinRTEnum (e.g. PedometerStepKind).

V must be of type Object, String, or WinRT (e.g. IJsonValue, ProductLicense).

creator must be specified if V is a WinRT type.

final mapView = IMapView<String, IJsonValue?>.fromRawPointer(ptr,
    creator: IJsonValue.fromRawPointer);

enumCreator must be specified if V is a WinRTEnum type.

final mapView = IMapView<String, ChatMessageStatus>.fromRawPointer(ptr,
    enumCreator: ChatMessageStatus.from);

Implementation

IMapView.fromRawPointer(
  super.ptr, {
  required String iterableIid,
  V Function(Pointer<COMObject>)? creator,
  K Function(int)? enumKeyCreator,
  V Function(int)? enumCreator,
})  : _iterableIid = iterableIid,
      _creator = creator,
      _enumKeyCreator = enumKeyCreator,
      _enumCreator = enumCreator {
  if (!isSupportedKeyValuePair<K, V>()) {
    throw ArgumentError('Unsupported key-value pair: IMapView<$K, $V>');
  }

  if (isSubtypeOfInspectable<V>() && creator == null) {
    throw ArgumentError.notNull('creator');
  }

  if (isSubtypeOfWinRTEnum<K>() && enumKeyCreator == null) {
    throw ArgumentError.notNull('enumKeyCreator');
  }

  if (isSubtypeOfWinRTEnum<V>() && enumCreator == null) {
    throw ArgumentError.notNull('enumCreator');
  }

  _iterableCreator = (Pointer<COMObject> ptr) => IKeyValuePair.fromRawPointer(
      ptr,
      creator: _creator,
      enumKeyCreator: _enumKeyCreator,
      enumCreator: _enumCreator);
}