decova-dotnet
Version:
This package provides fundumentals that a .net developer may miss while working with Typescript, whether they are missing functinalities or funcionalities provided in a non-elegant design in javascript. Bad naming, bad design of optional parameters, non-c
52 lines • 1.67 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TypeInfo = void 0;
const Exceptions_1 = require("../Exceptions/Exceptions");
class TypeInfo {
constructor(Type) {
this.Type = Type;
}
static of(type) {
return type.Type ? type : new TypeInfo(type);
}
isAssignableFrom(type) {
if (!type)
throw new Exceptions_1.Exception_ArgumentNull('type');
let stepConstructor;
if (type.constructor === TypeInfo) {
stepConstructor = type.Type;
}
else {
stepConstructor = type;
}
if (!type)
throw new Exceptions_1.Exception_InvalidProgramState('typeConstructor', 'typeConstructor should not be null here!');
do {
if (this.Type === stepConstructor) {
return true;
}
stepConstructor = Object.getPrototypeOf(stepConstructor);
} while (stepConstructor);
return false;
}
static GetDecoratedConstructor(constructor) {
while (!!constructor && !constructor.name) {
constructor = Object.getPrototypeOf(constructor);
}
return constructor;
}
static ofObject(obj) {
if (!obj)
throw new Exceptions_1.Exception_ArgumentNull('obj');
let type = obj.constructor;
while (!!type && !type.name) {
type = Object.getPrototypeOf(type);
}
return new TypeInfo(type);
}
get typeName() {
return this.Type.name;
}
}
exports.TypeInfo = TypeInfo;
//# sourceMappingURL=TypeInfo.js.map