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


TypeScript Metadata.getParamTypes方法代码示例

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


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

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

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

示例3: return

  return (target: any, propertyKey: string, parameterIndex: number): void => {
    const type = getDecoratorType([target, propertyKey, parameterIndex], true);

    switch (type) {
      default:
        throw new Error("MultipartFile is only supported on parameters");

      case "parameter":
        const store = Store.fromMethod(target, propertyKey);
        const multiple = Metadata.getParamTypes(target, propertyKey)[parameterIndex] === Array;
        const options = typeof name === "object" ? name : undefined;
        const added = store.has("multipartAdded");

        name = (typeof name === "object" ? undefined : name)!;

        // create endpoint metadata
        store.merge("consumes", ["multipart/form-data"]).set("multipartAdded", true);
        store
          .merge("responses", {
            "400": {
              description: `<File too long | Too many parts | Too many files | Field name too long | Field value too long | Too many fields | Unexpected field>  [fieldName]
                            Example: File too long file1`
            }
          })
          .set("multipartAdded", true);

        if (!added) {
          // middleware is added
          UseBefore(MultipartFileMiddleware)(target, propertyKey, descriptorOf(target, propertyKey));
        }

        if (name === undefined) {
          store.merge(MultipartFileMiddleware, {
            options,
            any: true
          });

          ParamRegistry.useFilter(multiple ? MultipartFilesFilter : MultipartFileFilter, {
            propertyKey,
            parameterIndex,
            target,
            useConverter: false,
            paramType: ParamTypes.FORM_DATA
          });
        } else {
          const expression = multiple ? (name as string) : name + ".0";

          store.merge(MultipartFileMiddleware, {
            fields: [
              {
                name,
                maxCount
              }
            ],
            options
          });

          ParamRegistry.useFilter(MultipartFilesFilter, {
            expression,
            propertyKey,
            parameterIndex,
            target,
            useConverter: false,
            paramType: ParamTypes.FORM_DATA
          });
        }

        break;
    }
  };
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:70,代码来源:multipartFile.ts


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