isSupportedKeyValuePair<K, V> function

bool isSupportedKeyValuePair<K, V>()

Determines whether K and V key-value pair is supported.

Supported key-value pairs are: IKeyValuePair<int, IInspectable?>, IKeyValuePair<Guid, IInspectable?>, IKeyValuePair<Guid, Object?>, IKeyValuePair<PedometerStepKind, PedometerReading?>, IKeyValuePair<Object, Object?>, IKeyValuePair<String, Object?>, IKeyValuePair<String, String>, IKeyValuePair<String, IInspectable?>, IKeyValuePair<String, WinRTEnum>.

isSupportedKeyValuePair<Guid, SpatialSurfaceInfo?>(); // true
isSupportedKeyValuePair<String, Object?>(); // true

Implementation

bool isSupportedKeyValuePair<K, V>() {
  // e.g. IKeyValuePair<int, IBuffer?>
  if (isSameType<K, int>() && isSubtypeOfInspectable<V>()) {
    return true;
  }

  // e.g. IKeyValuePair<Guid, SpatialSurfaceInfo?>, IKeyValuePair<Guid, Object?>
  if (isSameType<K, Guid>() &&
      (isSubtypeOfInspectable<V>() || isSimilarType<V, Object>())) {
    return true;
  }

  // e.g. IKeyValuePair<PedometerStepKind, PedometerReading?>
  if (isSubtypeOfWinRTEnum<K>() && isSubtypeOfInspectable<V>()) {
    return true;
  }

  // e.g. IKeyValuePair<Object, Object?>
  if (isSameType<K, Object>() && isSimilarType<V, Object>()) {
    return true;
  }

  // e.g. IKeyValuePair<String, Object?>, IKeyValuePair<String, String>,
  // IKeyValuePair<String, IJsonValue?>, IKeyValuePair<String, ChatMessageStatus>
  if (isSameType<K, String>() &&
      (isSimilarType<V, Object?>() ||
          isSameType<V, String>() ||
          isSubtypeOfInspectable<V>() ||
          isSubtypeOfWinRTEnum<V>())) {
    return true;
  }

  return false;
}