UNPKG

tsioc

Version:

tsioc is AOP, Ioc container, via typescript decorator

65 lines (63 loc) 2.79 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var index_1 = require("../../core/index"); var AopActions_1 = require("./AopActions"); var isValideAspectTarget_1 = require("../isValideAspectTarget"); var index_2 = require("../../utils/index"); var BindMethodPointcutAction = /** @class */ (function (_super) { __extends(BindMethodPointcutAction, _super); function BindMethodPointcutAction() { return _super.call(this, AopActions_1.AopActions.bindMethodPointcut) || this; } BindMethodPointcutAction.prototype.working = function (container, data) { // aspect class do nothing. if (!data.target || !isValideAspectTarget_1.isValideAspectTarget(data.targetType)) { return; } var proxy = container.get(index_2.symbols.IProxyMethod); var target = data.target; var targetType = data.targetType; var className = targetType.name; var methods = []; var decorators = Object.getOwnPropertyDescriptors(targetType.prototype); Object.keys(decorators).forEach(function (name) { if (name === 'constructor') { return; } methods.push({ name: name, fullName: className + "." + name, descriptor: decorators[name] }); }); var allmethods = index_1.getParamerterNames(targetType); Object.keys(allmethods).forEach(function (name) { if (name === 'constructor') { return; } if (index_2.isUndefined(decorators[name])) { methods.push({ name: name, fullName: className + "." + name }); } }); methods.forEach(function (pointcut) { proxy.proceed(target, targetType, pointcut, target['_cache_JoinPoint']); }); }; BindMethodPointcutAction.classAnnations = { "name": "BindMethodPointcutAction", "params": { "constructor": [], "working": ["container", "data"] } }; return BindMethodPointcutAction; }(index_1.ActionComposite)); exports.BindMethodPointcutAction = BindMethodPointcutAction; //# sourceMappingURL=../sourcemaps/actions/BindMethodPointcutAction.js.map