Class Type

Provides a typing and type-reflection system for ECMAScript (JavaScript) object-oriented programming functionality. Type Class

see

{@link http://msdn.microsoft.com/en-us/library/bb397568(v=vs.100).aspx}

Index

Methods

Methods

public callBaseMethod(instance: any, name: string, baseArguments?: Array<any>): any

Invokes a base method with specified arguments.

Parameters

  • instance: any
  • name: string
  • baseArguments?: Array<any> optional

Returns

any

A value of the class that the base method returns. If the base method does not return a value, no value is returned.

public static createCallback(method: Function, context: Object): Function

Creates a callback method, given the function to callback and the parameter to pass to it.

Parameters

  • method: Function
          The function for which the callback method will be created.
    
  • context: Object
          The parameter to pass to the function. This parameter can be null, but it cannot be omitted.
    

Returns

Function

  The callback function.

public static createDelegate(instance: Object, method: Function): Function

Creates a delegate function that keeps the context from its creation. The context defines the object instance to which the this keyword points.

Parameters

  • instance: Object
          The object instance that will be the context for the function. This parameter can be null.
    
  • method: Function
          The function from which the delegate is created.
    

Returns

Function

The delegate function.

public getBaseMethod(instance: Object, name: string): any

Returns the base implementation of a method from the base class of the specified instance.

Parameters

  • instance: Object
         The instance for which the base method is requested.
    
  • name: string
         The name of the method to retrieve as a reference.
    

Returns

any

public getBaseType(): Type

Returns the base class of the instance. Use the getBaseType method to retrieve the base class of the instance.

Returns

Type

public getInterfaces(): Array<any>

Returns an Array object that contains the list of interfaces that the type implements. Use the getInterfaces function to return a list of objects that define the interfaces on a type object. This enables you to enumerate the array to determine the object's interfaces.

Returns

Array<any>

An Array object that contains the list of interfaces that the type implements.

public getName(): string

Returns the name of the type of the instance.

example

Object.getType(c[i]).getName()

Returns

string

A string representing the fully qualified name of the type of the instance.

public static getRootNamespaces(): any

Returns an Array object containing references to all the root namespaces of the client application. This method is static and is invoked without creating an instance of the object. Use the getRootNamespaces function to return an array containing references to all the root namespaces of the client application.

Returns

any

An object containing references to all the root namespaces of the client application.

public implementsInterface(interfaceType: Type): boolean

Determines whether a class implements a specified interface type.

Parameters

  • interfaceType: Type
          The interface to test.
    

Returns

boolean

true if the class implements interfaceType; otherwise, false.

public inheritsFrom(parentType: string): boolean

Determines whether an instance inherits from a specified class.

Parameters

  • parentType: string
          The fully qualified name of the class to test as a base class for the current instance.
    

Returns

boolean

true if the instance inherits from parentType; otherwise, false.

public initializeBase(instance: any, baseArguments?: Array<any>): any

Initializes the base class and its members in the context of a given instance, which provides the model for inheritance and for initializing base members.

Parameters

  • instance: any
          The instance to initialize the base class for. Usually this.
    
  • baseArguments?: Array<any> optional
          (Optional) The arguments for the base constructor. Can be null.
    

Returns

any

public static isClass(type: any): boolean

Returns a value that indicates whether the specified type is a class. This method is static and can be invoked without creating an instance of the object.

Parameters

  • type: any
          The type to test.
    

Returns

boolean

true if the specified type is a class; otherwise, false.

public static isEnum(type: any): boolean

Indicates whether the specified type is an enumeration.

Parameters

  • type: any
          The type to test.
    

Returns

boolean

true if the type is an enumeration; otherwise, false.

public static isFlags(type: any): boolean

Get a value that indicates whether the specified type is an integer of flags.

Parameters

  • type: any

Returns

boolean

true if the type is an integer of flags; otherwise, false.

public isImplementedBy(typeInstanceVar: any): boolean

Determines whether an instance implements an interface.

Parameters

  • typeInstanceVar: any
          The instance on which the interface is tested.
    

Returns

boolean

public isInstanceOfType(instance: any): boolean

Returns a value that indicates whether an object is an instance of a specified class or of one of its derived classes.

Parameters

  • instance: any
          The object to test.
    

Returns

boolean

true if instance is an instance of the class; false if instance does not implement the interface, or if it is undefined or null.

public static isInterface(type: any): boolean

Returns a value that indicates whether the specified type is an interface. This is a static member that is invoked directly without creating an instance of the class.

Parameters

  • type: any
          The type to test.
    

Returns

boolean

true if the specified type is an interface; otherwise, false.

public static isNamespace(object: any): boolean

Returns a value that indicates whether the specified object is a namespace. This is a static member that is invoked directly without creating an instance of the class.

Parameters

  • object: any
          The object to test.
    

Returns

boolean

true if the specified object is a namespace; otherwise, false.

public static parse(typeName: string, ns?: string): any

Returns an instance of the type specified by a type name. This is a static member that is invoked directly without creating an instance of its class.

Parameters

  • typeName: string
          A string that represents a fully qualified class name. Can be null.
    
  • ns?: string optional
          (Optional) The namespace that contains the class.
    

Returns

any

The class represented by typeName, or null if a class that matches typeName does not occur in the namespace.

public registerClass(typeName: string, baseType?: any, interfaceTypes?: Array<any>): any

Registers a class as defined by a constructor with an optional base type and interface type.

Parameters

  • typeName: string
          A string that represents the fully qualified name of the type.
    
  • baseType?: any optional
          (Optional) The base type.
    
  • interfaceTypes?: Array<any> optional
          (Optional) An unbounded array of interface type definitions that the type implements.
    

Returns

any

The registered type.

public registerEnum(name: string, flags?: boolean)

Registers an enumeration.

Parameters

  • name: string
          The fully-qualified name of the enumeration.
    
  • flags?: boolean optional
          (Optional) true if the enumeration is a collection of flags; otherwise, false.
    

public registerInterface(typeName: string): any

Registers an interface defined by a constructor.

Parameters

  • typeName: string
          A string that represents the fully qualified name of the class to be registered as an interface.
    

Returns

any

The registered interface.

public static registerNamespace(namespacePath: string)

Creates a namespace. This member is static and can be invoked without creating an instance of the class.

Parameters

  • namespacePath: string
          A string that represents the fully qualified namespace to register.
    

public resolveInheritance()

Copies members from the base class to the prototype associated with the derived class, and continues this process up the inheritance chain. This enables you to reflect on the inherited members of a derived type. Use the resolveInheritance method to reflect on the inherited members of a derived type. You invoke this method from the type that you want to reflect on. The resolveInheritance method copies members from the base class to the prototype associated with the derived class, and continues this process up the inheritance chain. If the derived type overrides a base type member, the base type member is not copied to the derived type's prototype. After invoking a derived type's resolveInheritance method, you can examine the members of the derived type to discover all members, which includes inherited members.