• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript core.Metadata类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中@tsed/core.Metadata的典型用法代码示例。如果您正苦于以下问题:TypeScript Metadata类的具体用法?TypeScript Metadata怎么用?TypeScript Metadata使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Metadata类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: getOwnEndpoints

  /**
   * Return all endpoints from the given class. This method doesn't return the endpoints from the parent of the given class.
   * @param {Type<any>} target
   * @returns {any}
   */
  static getOwnEndpoints(target: Type<any>) {
    if (!this.hasEndpoints(target)) {
      Metadata.set("endpoints", [], target);
    }

    return Metadata.getOwn("endpoints", target);
  }
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:12,代码来源:EndpointRegistry.ts


示例2: get

  /**
   * Get an endpoint.
   * @param target
   * @param method
   */
  static get(target: Type<any>, method: string): EndpointMetadata {
    if (!this.has(target, method)) {
      const endpoint = new EndpointMetadata(target, method);
      this.getOwnEndpoints(target).push(endpoint);
      Metadata.set("endpoints", endpoint, target, method);
    }

    return Metadata.getOwn("endpoints", target, method);
  }
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:14,代码来源:EndpointRegistry.ts


示例3: set

  /**
   *
   * @param target
   * @param propertyKey
   * @param property
   */
  static set(target: Type<any>, propertyKey: string | symbol, property: PropertyMetadata): void {
    const properties = this.getOwnProperties(target);

    properties.set(propertyKey, property);

    Metadata.set(PROPERTIES_METADATA, properties, target);
  }
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:13,代码来源:PropertyRegistry.ts


示例4: return

  return (target: any, propertyKey: string, index: number) => {
    const store = Store.from(target);
    const type = Metadata.getParamTypes(target, propertyKey)[index];
    const param = {
      filter: SocketFilters.ARGS,
      useConverter: false
    };

    if (mapIndex !== undefined) {
      Object.assign(param, {
        mapIndex,
        useConverter: true,
        type: useType || type,
        collectionType: isCollection(type) ? type : undefined
      });
    }

    return store.merge("socketIO", {
      handlers: {
        [propertyKey]: {
          parameters: {
            [index]: param
          }
        }
      }
    });
  };
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:27,代码来源:args.ts


示例5: return

  return (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<Function> | number): any => {
    const bindingType = getDecoratorType([target, propertyKey, descriptor], true);

    switch (bindingType) {
      case "parameter":
      case "parameter.constructor":
        if (symbol) {
          const paramTypes = Metadata.getParamTypes(target, propertyKey);

          paramTypes[descriptor as number] = symbol;
          Metadata.setParamTypes(target, propertyKey, paramTypes);
        }
        break;

      case "property":
        Store.from(target).merge("injectableProperties", {
          [propertyKey]: {
            bindingType,
            propertyKey,
            useType: symbol || Metadata.getType(target, propertyKey)
          }
        });
        break;

      case "method":
        Store.from(target).merge("injectableProperties", {
          [propertyKey]: {
            bindingType,
            propertyKey
          }
        });

        return descriptor;

      default:
        throw new UnsupportedDecoratorType(Inject, [target, propertyKey, descriptor]);
    }
  };
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:38,代码来源:inject.ts


示例6: before

    before(() => {
      this.endpointMetadata = new EndpointMetadata(Test, "method");

      this.endpointMetadata.path = "/";
      this.endpointMetadata.httpMethod = "get";
      this.endpointMetadata.beforeMiddlewares = [() => {}];
      this.endpointMetadata.middlewares = [() => {}];
      this.endpointMetadata.afterMiddlewares = [() => {}];
      this.endpointMetadata.before([() => {}]);
      this.endpointMetadata.after([() => {}]);

      EndpointRegistry.store(Test, "method").set("test", "value");

      Metadata.set("design:returntype", Object, Test, "method");

      this.store = {};
      this.endpointMetadata.store.forEach((v: any, k: any) => (this.store[k] = v));
    });
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:18,代码来源:EndpointMetadata.spec.ts


示例7: before

  before(() => {
    class TestServer extends ServerLoader {
      $onInit() {
      }

      $onReady() {
      }

      $onMountingMiddlewares() {
      }

      $afterRoutesInit() {
      }
    }

    Metadata.set(SERVER_SETTINGS, {debug: true, port: 8000, httpsPort: 8080}, TestServer);

    this.server = new TestServer();
    this.server.settings.httpPort = 8080;
    this.server.settings.httpsPort = 8000;
    this.useStub = Sinon.stub(this.server.expressApp, "use");
    this.setStub = Sinon.stub(this.server.expressApp, "set");
    this.engineStub = Sinon.stub(this.server.expressApp, "engine");
  });
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:24,代码来源:ServerLoader.spec.ts


示例8: has

 /**
  * Gets a value indicating whether the target object or its prototype chain has already method registered.
  * @param target
  * @param method
  */
 static has(target: Type<any>, method: string): boolean {
   return Metadata.hasOwn("endpoints", target, method);
 }
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:8,代码来源:EndpointRegistry.ts


示例9: hasEndpoints

 /**
  * Gets a value indicating whether the target object or its prototype chain has endpoints.
  * @param {Type<any>} target
  * @returns {boolean}
  */
 static hasEndpoints(target: Type<any>) {
   return Metadata.hasOwn("endpoints", target);
 }
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:8,代码来源:EndpointRegistry.ts


示例10: getOwnProperties

 /**
  *
  * @param {Type<any>} target
  * @returns {Map<string | symbol, PropertyMetadata>}
  */
 static getOwnProperties(target: Type<any>): Map<string | symbol, PropertyMetadata> {
   return Metadata.hasOwn(PROPERTIES_METADATA, target)
     ? Metadata.getOwn(PROPERTIES_METADATA, target)
     : new Map<string | symbol, PropertyMetadata>();
 }
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:10,代码来源:PropertyRegistry.ts



注:本文中的@tsed/core.Metadata类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript core.Store类代码示例发布时间:2022-05-28
下一篇:
TypeScript core.nameOf函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap