本文整理汇总了TypeScript中@nakedobjects/services.ContextService.getObjectCachedValues方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ContextService.getObjectCachedValues方法的具体用法?TypeScript ContextService.getObjectCachedValues怎么用?TypeScript ContextService.getObjectCachedValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@nakedobjects/services.ContextService
的用法示例。
在下文中一共展示了ContextService.getObjectCachedValues方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: valueForUrl
protected valueForUrl(val: Ro.Value, field: Ro.IField): Ro.Value | null {
if (val.isNull()) { return val; }
const fieldEntryType = field.entryType();
if (fieldEntryType !== Ro.EntryType.FreeForm || field.isCollectionContributed()) {
if (this.isMultiChoiceField(field) || field.isCollectionContributed()) {
let valuesFromRouteData: Ro.Value[] | null = new Array<Ro.Value>();
if (field instanceof Ro.Parameter) {
const rd = Commandresult.getParametersAndCurrentValue(field.parent, this.context)[field.id()];
if (rd) { valuesFromRouteData = rd.list(); } // TODO: what if only one?
} else if (field instanceof Ro.PropertyMember) {
const obj = field.parent as Ro.DomainObjectRepresentation;
const props = this.context.getObjectCachedValues(obj.id());
const rd = props[field.id()];
if (rd) { valuesFromRouteData = rd.list(); } // TODO: what if only one?
}
let vals: Ro.Value[] = [];
if (val.isReference() || val.isScalar()) {
vals = new Array<Ro.Value>(val);
} else if (val.isList()) { // Should be!
vals = val.list()!;
}
valuesFromRouteData = valuesFromRouteData || [];
forEach(vals, v => this.addOrRemoveValue(valuesFromRouteData!, v));
if (vals[0].isScalar()) { // then all must be scalar
const scalars = map(valuesFromRouteData, v => v.scalar());
return new Ro.Value(scalars);
} else { // assumed to be links
const links: Ro.ILink[] = map(valuesFromRouteData, v => ({ href: v.link()!.href(), title: Ro.withUndefined(v.link()!.title()) }));
return new Ro.Value(links.length > 0 ? links : null);
}
}
if (val.isScalar()) {
return val;
}
// reference
return this.leanLink(val);
}
if (val.isScalar()) {
if (val.isNull()) {
return new Ro.Value('');
}
return val;
// TODO: consider these options:
// if (from.value instanceof Date) {
// return new Value((from.value as Date).toISOString());
// }
// return new Value(from.value as number | string | boolean);
}
if (val.isReference()) {
return this.leanLink(val);
}
return null;
}