getView method

Map<K, V> getView()

Returns an immutable view of the map.

Implementation

Map<K, V> getView() {
  final retValuePtr = calloc<COMObject>();

  final hr = ptr.ref.lpVtbl.value
          .elementAt(9)
          .cast<
              Pointer<
                  NativeFunction<
                      HRESULT Function(Pointer, Pointer<COMObject>)>>>()
          .value
          .asFunction<int Function(Pointer, Pointer<COMObject>)>()(
      ptr.ref.lpVtbl, retValuePtr);

  if (FAILED(hr)) throw WindowsException(hr);

  final mapView = IMapView<K, V>.fromRawPointer(retValuePtr,
      creator: _creator,
      enumCreator: _enumCreator,
      iterableIid: _iterableIid);
  final map = mapView.toMap();
  mapView.release();

  return map;
}