Converts an object to and from a string representation.

2.0

interface IDataFormatter {
    Cast<T1, T2>(this: T2, type: TypeRef<T1>): T1;
    Format(obj: any): string;
    Format(obj: any): string;
    FormatInvalid(error: string | String): string;
    Parse(str: string | String): unknown;
    TryCast<T1, T2>(this: T2, type: TypeRef<T1>): null | T1;
    TryParse(str: string | String, result: OutParam<System.Object>): boolean;
}

Hierarchy (view full)

Implemented by

Methods

Default capability

Methods

  • Casts this object to the specified type. Throws error on failure.

    Type Parameters

    • T1

      The target type of the cast.

    • T2

      The type of the object to cast.

    Parameters

    Returns T1

  • Casts this object to the specified type. Returns null on failure.

    Type Parameters

    • T1

      The target type of the cast.

    • T2

      The type of the object to cast.

    Parameters

    Returns null | T1

Default capability

  • Converts an object to a string representation.

    Parameters

    • obj: any

      The object to convert.

    Returns string

    A string representation.

    2.0

  • Converts an object to a string representation.

    Parameters

    • obj: any

      The object to convert.

    Returns string

    A string representation.

    2.0

  • Formats an invalid value with an optional error string.

    Parameters

    • error: string | String

      An error string. Optional (may be null).

    Returns string

    A string value

    2.0

  • Converts a string representation to an object.

    Parameters

    • str: string | String

      The string to convert.

    Returns unknown

    An object.

    2.0

  • Converts a string representation to an object. A return value indicates whether the conversion succeeded or failed.

    Parameters

    Returns boolean

    true if str was converted successfully; otherwise, false.

    2.0