/
NavigationPropertyTypeConverter.ts
45 lines (41 loc) · 1.38 KB
/
NavigationPropertyTypeConverter.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/**
* @packageDocumentation
* @module TypeConverters
*/
import type { Primitives, PropertyDescription } from "@itwin/appui-abstract";
import { StandardTypeNames } from "@itwin/appui-abstract";
import { TypeConverter } from "./TypeConverter";
import { TypeConverterManager } from "./TypeConverterManager";
/**
* Navigation property type converter.
* @public
*/
export class NavigationPropertyTypeConverter extends TypeConverter {
public override convertPropertyToString(
propertyDescription: PropertyDescription,
value?: Primitives.Value
) {
return value === undefined ? "" : propertyDescription.displayLabel;
}
public sortCompare(
a: Primitives.Value,
b: Primitives.Value,
ignoreCase?: boolean
): number {
return TypeConverterManager.getConverter(
StandardTypeNames.Hexadecimal
).sortCompare(
(a as Primitives.InstanceKey).id,
(b as Primitives.InstanceKey).id,
ignoreCase
);
}
}
TypeConverterManager.registerConverter(
StandardTypeNames.Navigation,
NavigationPropertyTypeConverter
);