packageDocumentation module import { Id64 } from "@itwin/core-bentley" ; import { Primitives , StandardTypeNames } from "@itwin/appui-abstract" ; import { TypeConverter } from "./TypeConverter" ; import { TypeConverterManager } from "./TypeConverterManager" ; public export class HexadecimalTypeConverter extends TypeConverter { public override convertToString ( value ? ) { if ( value === undefined ) return "" ; const hexString = value . toString ( ) ; return `0x${ hexString . substring ( 2 , hexString . length ) . toUpperCase ( ) }` ; } public override convertFromString ( value ) { if ( value . substr ( 0 , 2 ) !== "0x" ) value = `0x${ value }` ; value = Id64 . fromString ( value ) ; if ( Id64 . isValidId64 ( value ) ) return value ; return undefined ; } public sortCompare ( a , b ) { a = Id64 . fromString ( a ) ; b = Id64 . fromString ( b ) ; if ( a === b ) return 0 ; if ( a > b ) return 1 ; return - 1 ; } } TypeConverterManager . registerConverter ( StandardTypeNames . Hex , HexadecimalTypeConverter ) ; TypeConverterManager . registerConverter ( StandardTypeNames . Hexadecimal , HexadecimalTypeConverter ) ;