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