import {PersistentAnnotation} from '../PersistentAnnotation'; import {PersistentFactory} from '../PersistentFactory'; import {FieldConverter} from './FieldConverter'; /** * 数组编号持久化器。 * * @param item 内容 * @param config 设置 * @param annotation 描述器 */ export class StringConverter extends FieldConverter { /** * 加载设置信息。 * * @param factory 工厂 * @param context 环境 * @param item 内容 * @param config 设置 * @param annotation 描述器 */ public load(factory: PersistentFactory, context: any, item: any, config: any, annotation?: PersistentAnnotation) { var name = annotation.name; var dataName = annotation.dataName; var value = config[dataName]; if (value == null) { value = annotation.dataDefault; } item[name] = value; } /** * 存储设置信息。 * * @param factory 工厂 * @param context 环境 * @param item 内容 * @param config 设置 * @param annotation 描述器 */ public save(factory: PersistentFactory, context: any, item: any, config: any, annotation?: PersistentAnnotation) { var name = annotation.name; var dataName = annotation.dataName; var value = item[name]; if (value != null) { if (value.length > 0) { config[dataName] = value; } } } }