user.config.ts文件里定义的配置是如何合并到SAP Spartacus的标准配置里去的
2023-09-14 09:04:01 时间
user.config.ts文件里提供的默认配置:
- userRoutingConfig
- userCmsConfig
- userTableConfigFactory - function
provideDefaultConfig的实现:
export function provideDefaultConfig(config: any = {}): ValueProvider {
return {
provide: DefaultConfigChunk,
useValue: config,
multi: true,
};
}
运行时,作为 SAP Spartacus global configuration object这个庞大的配置对象,就是从一个个module里提供的默认配置,一点点合并而成的。
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { ConfigModule } from '../../../config/config.module';
import {
COST_CENTERS_NORMALIZER,
COST_CENTER_NORMALIZER,
COST_CENTER_SERIALIZER,
} from '../../../cost-center/connectors/cost-center/converters';
import { OccCostCenterListNormalizer } from './converters/occ-cost-center-list-normalizer';
import { OccCostCenterNormalizer } from './converters/occ-cost-center-normalizer';
import { OccCostCenterSerializer } from './converters/occ-cost-center-serializer';
import { defaultOccCostCentersConfig } from './default-occ-cost-centers-config';
@NgModule({
imports: [CommonModule, ConfigModule.withConfig(defaultOccCostCentersConfig)],
providers: [
{
provide: COST_CENTERS_NORMALIZER,
useExisting: OccCostCenterListNormalizer,
multi: true,
},
{
provide: COST_CENTER_NORMALIZER,
useExisting: OccCostCenterNormalizer,
multi: true,
},
{
provide: COST_CENTER_SERIALIZER,
useExisting: OccCostCenterSerializer,
multi: true,
},
],
})
export class CostCenterOccModule {}
withConfig的实现:
import { ModuleWithProviders, NgModule } from '@angular/core';
import { provideConfig, provideConfigFactory } from './config-providers';
import { ConfigurationService } from './services/configuration.service';
@NgModule({})
export class ConfigModule {
// To make sure ConfigurationService will be instantiated, we inject it into
// module constructor
constructor(_configurationService: ConfigurationService) {}
/**
* Import ConfigModule and contribute config to the global configuration
*
* To provide default configuration in libraries provideDefaultConfig should be used instead.
*
* @param config Config object to merge with the global configuration
*/
static withConfig(config: object): ModuleWithProviders<ConfigModule> {
return {
ngModule: ConfigModule,
providers: [provideConfig(config)],
};
}
/**
* Import ConfigModule and contribute config to the global configuration using factory function
*
* To provide default configuration in libraries provideDefaultConfigFactory should be used instead.
*
* @param configFactory Factory function that will generate configuration
* @param deps Optional dependencies to factory function
*/
static withConfigFactory(
configFactory: Function,
deps?: any[]
): ModuleWithProviders<ConfigModule> {
return {
ngModule: ConfigModule,
providers: [provideConfigFactory(configFactory, deps)],
};
}
/**
* Module with providers, should be imported only once, if possible, at the root of the app.
*
* @param config
*/
static forRoot(config: any = {}): ModuleWithProviders<ConfigModule> {
return {
ngModule: ConfigModule,
providers: [provideConfig(config)],
};
}
}
更多Jerry的原创文章,尽在:“汪子熙”:
相关文章
- SAP UI5 sap.ui.layout.Grid 控件宽度百分比的设置原理
- SAP UI5 应用中的 sap.ui.require.toUrl 使用场景
- SAP UI5 sap.ui.base.ManagedObject 的构造函数参数讲解
- 使用 SAP UI5 sap.ui.export.Spreadsheet API 进行 Excel 导出的一些限制
- SAP UI5 sap.ui.Device.media.RANGESETS.SAP_STANDARD_EXTENDED 介绍
- SAP UI5 sap.ui.Device.media 的使用介绍
- 通过一个实际例子,理解 SAP UI5 sap.ui.model.odata.v2.ODataModel API 中 BindingContext 绑定上下文的概念和用法试读版
- SAP OData 服务关于本地文件作为附件上传的一些错误消息
- 29. 如何通过 ABAP 代码给 SAP OData 元数据增添注解
- SAP UI5 sap.m.Table 实现响应式布局的两种配置模式
- SAP Fiori Launchpad url 参数 sap-app-origin-hint 的含义
- SAP自开发程序详解编程语言
- SAP的JSON没有双引号问题详解编程语言
- SAP 常用系统函数详解编程语言
- SAP 动态内表demo—-自用详解编程语言
- MM SAP报错整理详解编程语言
- SAP《MM学习指南》操作记录—-仓库盘点详解编程语言
- sap的日期,时间详解编程语言
- Reading and Writing data on application server in SAP详解编程语言
- SAP 发送邮件例子(外部)详解编程语言
- 系统SAP在Linux系统上的开启之旅(sap启动linux)
- 对比SAP VS Oracle: 哪个更适合你?(sap与oracle)
- Oracle与SAP在仓储领域的联姻(仓库oracle和sap)
- 深度比较:SAP vs Oracle(sap与oracle比较)
- 对比:Oracle 与 SAP的优势(oracle 与 sap)
- Oracle从SAP抽取数据的简单方法(oracle从sap抽数)
- 比拼Oracle与SAP的优劣对比(oracle与sap优劣)
- Oracle和SAP教程一步一步学习(oracle sap教程)