-
Notifications
You must be signed in to change notification settings - Fork 0
type registration
Typescript (JS) doesn't have a runtime type information system like C#. But most C# library's exploit the type information to do stuff. That's why we simulate a type system by registrering the types to the library.
Registering a class to the system is done by defining a static property called _type within the class. Type.registerClass is used with 3 parameters
- class
- the full name, including module naming, of the class as string
- array of string of the fullname interfaces the class implements
Sample
module System {
export class Guid extends System.Object implements ICloneable {
static _type: Type = Type.registerClass(Guid, "System.Guid", ["System.ICloneable"]);
}
}
Registering a interface to the system is done by calling the System.Type.registerInterface and passing the full interface name, with extended
sample
module System.Sample {
export interface IThing extends System.IOther {
someMethod() : void;
}
System.Type.registerInterface("System.Sample.IThing", "System.IOther");
}
##Register an Enumaration Registering an Enumaration to the system is done by typing System.Type.registerEnum and the enumaration and after the comma you type the string name.
Sample
module System
{
export enum SampleColor
{
Red,
White,
}
System.Type.registerEnum(SampleColor, "System.SampleColor");
}
Registering an Enumaration to the system is done by typing System.Type.registerEnum and the enumaration and after the comma you type the string name.
Sample
module System
{
export enum SampleColor
{
Red,
White,
}
System.Type.registerEnum(SampleColor, "System.SampleColor");
}