本文整理汇总了TypeScript中vs/platform/configuration/common/configurationModels.ConfigurationModel类的典型用法代码示例。如果您正苦于以下问题:TypeScript ConfigurationModel类的具体用法?TypeScript ConfigurationModel怎么用?TypeScript ConfigurationModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConfigurationModel类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('simple merge', () => {
let base = new ConfigurationModel({ 'a': 1, 'b': 2 }, ['a', 'b']);
let add = new ConfigurationModel({ 'a': 3, 'c': 4 }, ['a', 'c']);
let result = base.merge(add);
assert.deepEqual(result.contents, { 'a': 3, 'b': 2, 'c': 4 });
assert.deepEqual(result.keys, ['a', 'b', 'c']);
});
示例2: test
test('removeValue: remove a multi segemented key', () => {
let testObject = new ConfigurationModel({ 'a': { 'b': 1 } }, ['a.b']);
testObject.removeValue('a.b');
assert.deepEqual(testObject.contents, {});
assert.deepEqual(testObject.keys, []);
});
示例3: test
test('removeValue: remove a single segmented key', () => {
let testObject = new ConfigurationModel({ 'a': 1 }, ['a']);
testObject.removeValue('a');
assert.deepEqual(testObject.contents, {});
assert.deepEqual(testObject.keys, []);
});
示例4: test
test('setValueInOverrides adds a nested key to overrides if exist', () => {
let testObject = new ConfigurationModel({ 'a': 1, 'b': 1 }, ['a'], [{ identifiers: ['or'], contents: { 'a': { 'c': 1 } } }]);
testObject.setValueInOverrides('or', 'a.c', 2);
assert.deepEqual(testObject.overrides[0].contents, { 'a': { 'c': 2 } });
assert.deepEqual(testObject.override('or').contents, { 'a': { 'c': 2 }, 'b': 1 });
});
示例5: test
test('recursive merge', () => {
let base = new ConfigurationModel({ 'a': { 'b': 1 } }, ['a.b']);
let add = new ConfigurationModel({ 'a': { 'b': 2 } }, ['a.b']);
let result = base.merge(add);
assert.deepEqual(result.contents, { 'a': { 'b': 2 } });
assert.deepEqual(result.getValue('a'), { 'b': 2 });
assert.deepEqual(result.keys, ['a.b']);
});
示例6: test
test('setValueInOverrides adds new overrides if exist', () => {
let testObject = new ConfigurationModel({ 'a': 1, 'b': 1 }, ['a'], [{ identifiers: ['or1'], contents: { 'a': 2 } }]);
testObject.setValueInOverrides('or2', 'b', 2);
assert.deepEqual(testObject.overrides[0].contents, { 'a': 2 });
assert.deepEqual(testObject.overrides[1].contents, { 'b': 2 });
assert.deepEqual(testObject.override('or1').contents, { 'a': 2, 'b': 1 });
assert.deepEqual(testObject.override('or2').contents, { 'a': 1, 'b': 2 });
});