furystack-core
Version:
FuryStack framework, Core package
40 lines • 1.5 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const ModelDescriptor_1 = require("./ModelDescriptor");
class ModelDescriptorStore {
/**
* Gets the DecoratorDescriptor for the specified object
* @param obj The object to get the DecoratorDescriptor for.
*/
static GetDescriptor(obj) {
return this.descriptorsInternal.filter((k) => obj === k.Object || obj.prototype === k.Object)[0];
}
/**
* Gets the Entity Name for the specified model class
* @param obj The model to get the EntityName for
*/
static GetName(obj) {
return this.GetDescriptor(obj).Object.constructor.name;
}
/**
* Adds a value to the Decorator Descriptor store.
* Adds an entry for the Object if it not exist, appends the Entries otherwise.
* @param newValue The new Object and Key values
*/
static Add(entityTypeClass, descriptorEntry) {
const found = this.GetDescriptor(entityTypeClass);
if (!found) {
const entry = new ModelDescriptor_1.ModelDescriptor(entityTypeClass, [descriptorEntry]);
this.descriptorsInternal.push(entry);
}
else {
found.entries.push(descriptorEntry);
}
}
}
/**
* The list of DecoratorDescriptors for an Object
*/
ModelDescriptorStore.descriptorsInternal = [];
exports.ModelDescriptorStore = ModelDescriptorStore;
//# sourceMappingURL=ModelDescriptorStore.js.map