• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript services.ContextService类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中@nakedobjects/services.ContextService的典型用法代码示例。如果您正苦于以下问题:TypeScript ContextService类的具体用法?TypeScript ContextService怎么用?TypeScript ContextService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ContextService类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: drop

export function drop(context: ContextService, error: ErrorService, vm: FieldViewModel, newValue: IDraggableViewModel) {
    return context.isSubTypeOf(newValue.draggableType, vm.returnType).
        then((canDrop: boolean) => {
            if (canDrop) {
                vm.setNewValue(newValue);
                return true;
            }
            return false;
        }).
        catch((reject: ErrorWrapper) => error.handleError(reject));
}
开发者ID:NakedObjectsGroup,项目名称:NakedObjectsFramework,代码行数:11,代码来源:helpers-view-models.ts


示例2:

                        .subscribe((paneRouteData: PaneRouteData) => {
                            if (!paneRouteData.isEqualIgnoringReload(this.lastPaneRouteData)) {
                                // only remove messages if something more than reload flag has changed
                                this.context.clearMessages();
                                this.context.clearWarnings();
                            }

                            if (this.doSetup(paneRouteData)) {
                                this.lastPaneRouteData = paneRouteData;
                                this.setup(paneRouteData);
                            }
                        });
开发者ID:NakedObjectsGroup,项目名称:NakedObjectsFramework,代码行数:12,代码来源:pane.ts


示例3: setUp

    private setUp() {
        this.context.getUser().
            then((u: Ro.UserRepresentation) => this.user = u.wrapped()).
            catch((reject: ErrorWrapper) => this.error.handleError(reject));

        this.context.getVersion().
            then((v: Ro.VersionRepresentation) => this.serverVersion = v.wrapped()).
            catch((reject: ErrorWrapper) => this.error.handleError(reject));

        this.serverUrl = this.configService.config.appPath;

        this.applicationName = this.configService.config.applicationName;
    }
开发者ID:NakedObjectsGroup,项目名称:NakedObjectsFramework,代码行数:13,代码来源:application-properties-view-model.ts


示例4:

 return this.context.getObject(1, oid, this.routeData().interactionMode).then((obj: Ro.DomainObjectRepresentation) => {
     if (this.routeData().interactionMode === InteractionMode.Edit) {
         return this.context.getObjectForEdit(1, obj);
     } else {
         return obj; // To wrap a known object as a promise
     }
 });
开发者ID:NakedObjectsGroup,项目名称:NakedObjectsFramework,代码行数:7,代码来源:command.ts


示例5: 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;
    }
开发者ID:NakedObjectsGroup,项目名称:NakedObjectsFramework,代码行数:59,代码来源:command.ts


示例6: ngOnInit

    ngOnInit(): void {
        // expect dynamic-error to  have checked if the context has an error
        const errorWrapper = this.context.getError();
        const error = this.viewModelFactory.errorViewModel(errorWrapper);

        this.title = error.title;
        this.message = error.message;
        this.errorCode = error.errorCode;
        this.description = error.description;
        this.stackTrace = error.stackTrace;
    }
开发者ID:NakedObjectsGroup,项目名称:NakedObjectsFramework,代码行数:11,代码来源:error.component.ts


示例7: getObject

    protected getObject(): Promise<Ro.DomainObjectRepresentation> {
        const oid = Ro.ObjectIdWrapper.fromObjectId(this.routeData().objectId, this.keySeparator);
        // TODO: Consider view model & transient modes?

        return this.context.getObject(1, oid, this.routeData().interactionMode).then((obj: Ro.DomainObjectRepresentation) => {
            if (this.routeData().interactionMode === InteractionMode.Edit) {
                return this.context.getObjectForEdit(1, obj);
            } else {
                return obj; // To wrap a known object as a promise
            }
        });
    }
开发者ID:NakedObjectsGroup,项目名称:NakedObjectsFramework,代码行数:12,代码来源:command.ts


示例8: ngOnInit

    ngOnInit() {

        const errorWrapper = this.context.getError();
        if (errorWrapper) {
            this.customComponentService.getCustomErrorComponent(errorWrapper.category, errorWrapper.httpErrorCode || errorWrapper.clientErrorCode).then((c: Type<any>) => {
                const childComponent = this.componentFactoryResolver.resolveComponentFactory(c);
                this.parent.createComponent(childComponent);
            });
        } else {
            this.loggerService.warn('No error found returning to home page');
            this.urlManagerService.setHomeSinglePane();
        }
    }
开发者ID:NakedObjectsGroup,项目名称:NakedObjectsFramework,代码行数:13,代码来源:dynamic-error.component.ts


示例9: setPropertyValueinContext

 protected setPropertyValueinContext(obj: Ro.DomainObjectRepresentation, property: Ro.PropertyMember, urlVal: Ro.Value) {
     this.context.cachePropertyValue(obj, property, urlVal);
 }
开发者ID:NakedObjectsGroup,项目名称:NakedObjectsFramework,代码行数:3,代码来源:command.ts


示例10: setFieldValueInContext

 protected setFieldValueInContext(field: Ro.Parameter, val: Ro.Value) {
     this.context.cacheFieldValue(this.routeData().dialogId, field.id(), val);
 }
开发者ID:NakedObjectsGroup,项目名称:NakedObjectsFramework,代码行数:3,代码来源:command.ts



注:本文中的@nakedobjects/services.ContextService类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript services.UrlManagerService类代码示例发布时间:2022-05-28
下一篇:
TypeScript simple-api-client.SimpleAPIClient类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap