本文整理匯總了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))