A service for parsing strings into the native data type using IDataTypeParser instances.

interface IDataTypeParserService {
    enabled: boolean;
    lazyLoad: ((service) => void);
    serviceName: string;
    services: IServices;
    isActive(): boolean;
    parse(text, lookupKey, cultureId): DataTypeResolution<any>;
    find(lookupKey, cultureId, text): null | IDataTypeParser<any>;
    compatible(lookupKey, cultureId): null | IDataTypeParser<any>[];
    register(item): void;
    getAll(): IDataTypeParser<any>[];
    dispose(): void;
}

Hierarchy (view full)

Implemented by

Properties

enabled: boolean

Determines if the Parser service is active. When false, do not call parse().

lazyLoad: ((service) => void)

Sets up a function to lazy load the configuration when any of the other functions are called. This function can be set after some initial registration. It will be discarded immediately after its used.

Type declaration

serviceName: string
services: IServices

Provides access to services.

Methods

  • Parse the text supplied, attempting to create another value from it that will be returned. The new value may be a different data type, whether primitive or an object that you have registered with DataTypeIdentifier. If parsing fails, return an error message instead of a value. If the text is the empty string, it is up to the parser to determine what to do (return the empty string, null, a default value of the expected type, or an error message.) The implementation should not throw an exception for a parsing error. Exceptions are permitted for configuration errors, such as a missing culture. If no parser was available, it returns an error in DataTypeResolution.

    Parameters

    • text: string
    • lookupKey: string

      A lookup key that identifies the desired parser. This is expected to come from the valueHost.parserLookupKey or if null, valueHost.dataType. If no parser is found for this, the LookupKeyFallbackService is used to find another to try.

    • cultureId: string

      Such as 'en-US' and 'en'

    Returns DataTypeResolution<any>

  • If the user needs to abandon this instance, they should use this to clean up active resources (like timers) and to release memory that would stall the garbage collector from disposing this object. It should assign any object reference to undefined as a strong indicator that the object has been disposed.

    Returns void

Generated using TypeDoc v0.25.12