当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Metadata.set方法代码示例

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


在下文中一共展示了Metadata.set方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: return

 return (target: Type<any>) => {
   Metadata.set(SERVER_SETTINGS, settings, target);
 };
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:3,代码来源:serverSettings.ts

示例7:

 classes.forEach(clazz => Metadata.set(CONVERTER, target, clazz));
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:1,代码来源:converter.ts


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