How to use the aurelia-metadata.metadata.getOwn function in aurelia-metadata

To help you get started, we’ve selected a few aurelia-metadata examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aurelia / dependency-injection / src / injection.ts View on Github external
const deco = (target: DependencyCtor & { inject?: any }) => {
    if (!target.hasOwnProperty('inject')) {
      target.inject = (
        (metadata.getOwn(metadata.paramTypes, target) as Array) ||
        _emptyParameters
      ).slice();
      if (target.inject && target.inject.length > 0) {
        // TypeScript 3.0 metadata for "...rest" gives type "Object"
        // if last parameter is "Object", assume it's a ...rest and remove that
        // metadata.
        if (target.inject[target.inject.length - 1] === Object) {
          target.inject.splice(-1, 1);
        }
      }
    }
  };
github aurelia / dependency-injection / dist / aurelia-dependency-injection.js View on Github external
let deco = function(target) {
    if (!target.hasOwnProperty('inject')) {
      target.inject = (metadata.getOwn(metadata.paramTypes, target) || _emptyParameters).slice();
      // TypeScript 3.0 metadata for "...rest" gives type "Object"
      // if last parameter is "Object", assume it's a ...rest and remove that metadata.
      if (target.inject.length > 0 &&
          target.inject[target.inject.length - 1] === Object) {
        target.inject.pop();
      }
    }
  };
github aurelia / dependency-injection / dist / es2015 / aurelia-dependency-injection.js View on Github external
_createInvocationHandler(fn) {
        let dependencies;
        if (fn.inject === undefined) {
            dependencies =
                metadata.getOwn(metadata.paramTypes, fn) || _emptyParameters;
        }
        else {
            dependencies = [];
            let ctor = fn;
            while (typeof ctor === 'function') {
                dependencies.push(...getDependencies(ctor));
                ctor = Object.getPrototypeOf(ctor);
            }
        }
        const invoker = metadata.getOwn(metadata.invoker, fn) || classInvoker;
        const handler = new InvocationHandler(fn, invoker, dependencies);
        return this._onHandlerCreated !== undefined
            ? this._onHandlerCreated(handler)
            : handler;
    }
}
github aurelia / dependency-injection / dist / aurelia-dependency-injection.js View on Github external
_createInvocationHandler(fn: Function & { inject?: any }): InvocationHandler {
    let dependencies;

    if (fn.inject === undefined) {
      dependencies = metadata.getOwn(metadata.paramTypes, fn) || _emptyParameters;
    } else {
      dependencies = [];
      let ctor = fn;
      while (typeof ctor === 'function') {
        dependencies.push(...getDependencies(ctor));
        ctor = Object.getPrototypeOf(ctor);
      }
    }

    let invoker = metadata.getOwn(metadata.invoker, fn)
      || classInvokers[dependencies.length] || classInvokers.fallback;

    let handler = new InvocationHandler(fn, invoker, dependencies);
    return this._onHandlerCreated !== undefined ? this._onHandlerCreated(handler) : handler;
  }
}
github aurelia / dependency-injection / src / decorators.js View on Github external
let deco = function(target) {
    target.inject = metadata.getOwn(metadata.paramTypes, target) || _emptyParameters;
  };
github aurelia / dependency-injection / src / resolvers.js View on Github external
export function getDecoratorDependencies(target, name) {
  if (!target.hasOwnProperty('inject')) {
    Object.defineProperty(target, 'inject', {value: undefined, writable: true});
  }
  let dependencies = target.inject;
  if (typeof dependencies === 'function') {
    throw new Error('Decorator ' + name + ' cannot be used with "inject()".  Please use an array instead.');
  }
  if (!dependencies) {
    dependencies = metadata.getOwn(metadata.paramTypes, target).slice();
    target.inject = dependencies;
  }

  return dependencies;
}
github aurelia / dependency-injection / dist / native-modules / aurelia-dependency-injection.js View on Github external
Container.prototype._createInvocationHandler = function (fn) {
        var dependencies;
        if (fn.inject === undefined) {
            dependencies =
                metadata.getOwn(metadata.paramTypes, fn) || _emptyParameters;
        }
        else {
            dependencies = [];
            var ctor = fn;
            while (typeof ctor === 'function') {
                dependencies.push.apply(dependencies, getDependencies(ctor));
                ctor = Object.getPrototypeOf(ctor);
            }
        }
        var invoker = metadata.getOwn(metadata.invoker, fn) || classInvoker;
        var handler = new InvocationHandler(fn, invoker, dependencies);
        return this._onHandlerCreated !== undefined
            ? this._onHandlerCreated(handler)
            : handler;
    };
    return Container;
github aurelia / templating / dist / es2015 / aurelia-templating.js View on Github external
_copyInheritedProperties(container, target) {
    let behavior;
    let derived = target;

    while (true) {
      let proto = Object.getPrototypeOf(target.prototype);
      target = proto && proto.constructor;
      if (!target) {
        return;
      }
      behavior = metadata.getOwn(metadata.resource, target);
      if (behavior) {
        break;
      }
    }
    behavior.initialize(container, target);
    for (let i = 0, ii = behavior.properties.length; i < ii; ++i) {
      let prop = behavior.properties[i];

      if (this.properties.some(p => p.name === prop.name)) {
        continue;
      }

      new BindableProperty(prop).registerWith(derived, this);
    }
  }
};
github aurelia / dependency-injection / dist / es2015 / aurelia-dependency-injection.js View on Github external
const deco = (target) => {
        if (!target.hasOwnProperty('inject')) {
            target.inject = (metadata.getOwn(metadata.paramTypes, target) ||
                _emptyParameters).slice();
            if (target.inject && target.inject.length > 0) {
                if (target.inject[target.inject.length - 1] === Object) {
                    target.inject.splice(-1, 1);
                }
            }
        }
    };
    if (isInjectable(potentialTarget)) {