kentico-cloud-delivery
Version:
Official Kentico Cloud Delivery SDK
27 lines • 1.15 kB
JavaScript
import 'reflect-metadata';
export var ElementDecorators;
(function (ElementDecorators) {
var codenameMetadataKey = Symbol('codename');
var generateKey = function (name) { return codenameMetadataKey.toString() + ":" + name; };
/**
* Get the metadata entry saved by the decorator
* @param target - object instance
* @param elementName - Element name (code name from Kentico Cloud)
*/
function getPropertyName(target, elementName) {
return Reflect.getMetadata(generateKey(elementName), target);
}
ElementDecorators.getPropertyName = getPropertyName;
/**
* Decorator - creates metadata entry for the @target - Value is the property name.
* This will then be retrieved when resolving the element name
* @param value - Element code name
*/
function codename(value) {
return function (target, propertyKey) {
Reflect.defineMetadata(generateKey(value), propertyKey, target);
};
}
ElementDecorators.codename = codename;
})(ElementDecorators || (ElementDecorators = {}));
//# sourceMappingURL=element-decorators.js.map