本文整理汇总了TypeScript中@tsed/common.ConverterService类的典型用法代码示例。如果您正苦于以下问题:TypeScript ConverterService类的具体用法?TypeScript ConverterService怎么用?TypeScript ConverterService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConverterService类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: inject
inject([ServiceModel, ConverterService], (serviceModel: MongooseModel<ServiceModel>, converterService: ConverterService) => {
this.result = new serviceModel({
admins: [{role: "role"}]
});
this.converted = converterService.serialize(this.result);
})
示例2: function
target.prototype.serialize = function(options: IConverterOptions, converter: ConverterService) {
const {checkRequiredValue, ignoreCallback} = options;
return converter.serializeClass(this, {
type: getClass(target),
checkRequiredValue,
ignoreCallback
});
};
示例3: deserialize
deserialize(obj: any, done: any) {
try {
const user = this.converterService.deserialize(JSON.parse(obj), this.model);
done(null, user);
} catch (er) {
done(er);
}
}
示例4:
Object.keys(parameters || []).forEach((index: any) => {
const {filter, useConverter, mapIndex, type, collectionType} = parameters![index];
let value = scope.args[mapIndex!];
if (filter === SocketFilters.ARGS && useConverter) {
value = this.converterService.deserialize(value, type, collectionType);
scope.args[mapIndex!] = value;
}
});
示例5: serialize
serialize(user: UserInfo, done: any) {
try {
const obj = this.converterService.serialize(user);
delete obj.password;
done(null, JSON.stringify(obj));
} catch (er) {
done(er);
}
}
示例6: test
Object.keys(collection).forEach((key: any) =>
test(this.converterService.deserialize(collection[key], targetType, undefined, options))