1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var binding_on_syntax_1 = require("./binding_on_syntax");
var constraint_helpers_1 = require("./constraint_helpers");
var BindingWhenSyntax = (function () {
function BindingWhenSyntax(binding) {
this._binding = binding;
}
BindingWhenSyntax.prototype.when = function (constraint) {
this._binding.constraint = constraint;
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
};
BindingWhenSyntax.prototype.whenTargetNamed = function (name) {
this._binding.constraint = constraint_helpers_1.namedConstraint(name);
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
};
BindingWhenSyntax.prototype.whenTargetIsDefault = function () {
this._binding.constraint = function (request) {
var targetIsDefault = (request.target !== null) &&
(!request.target.isNamed()) &&
(!request.target.isTagged());
return targetIsDefault;
};
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
};
BindingWhenSyntax.prototype.whenTargetTagged = function (tag, value) {
this._binding.constraint = constraint_helpers_1.taggedConstraint(tag)(value);
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
};
BindingWhenSyntax.prototype.whenInjectedInto = function (parent) {
this._binding.constraint = function (request) {
return constraint_helpers_1.typeConstraint(parent)(request.parentRequest);
};
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
};
BindingWhenSyntax.prototype.whenParentNamed = function (name) {
this._binding.constraint = function (request) {
return constraint_helpers_1.namedConstraint(name)(request.parentRequest);
};
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
};
BindingWhenSyntax.prototype.whenParentTagged = function (tag, value) {
this._binding.constraint = function (request) {
return constraint_helpers_1.taggedConstraint(tag)(value)(request.parentRequest);
};
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
};
BindingWhenSyntax.prototype.whenAnyAncestorIs = function (ancestor) {
this._binding.constraint = function (request) {
return constraint_helpers_1.traverseAncerstors(request, constraint_helpers_1.typeConstraint(ancestor));
};
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
};
BindingWhenSyntax.prototype.whenNoAncestorIs = function (ancestor) {
this._binding.constraint = function (request) {
return !constraint_helpers_1.traverseAncerstors(request, constraint_helpers_1.typeConstraint(ancestor));
};
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
};
BindingWhenSyntax.prototype.whenAnyAncestorNamed = function (name) {
this._binding.constraint = function (request) {
return constraint_helpers_1.traverseAncerstors(request, constraint_helpers_1.namedConstraint(name));
};
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
};
BindingWhenSyntax.prototype.whenNoAncestorNamed = function (name) {
this._binding.constraint = function (request) {
return !constraint_helpers_1.traverseAncerstors(request, constraint_helpers_1.namedConstraint(name));
};
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
};
BindingWhenSyntax.prototype.whenAnyAncestorTagged = function (tag, value) {
this._binding.constraint = function (request) {
return constraint_helpers_1.traverseAncerstors(request, constraint_helpers_1.taggedConstraint(tag)(value));
};
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
};
BindingWhenSyntax.prototype.whenNoAncestorTagged = function (tag, value) {
this._binding.constraint = function (request) {
return !constraint_helpers_1.traverseAncerstors(request, constraint_helpers_1.taggedConstraint(tag)(value));
};
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
};
BindingWhenSyntax.prototype.whenAnyAncestorMatches = function (constraint) {
this._binding.constraint = function (request) {
return constraint_helpers_1.traverseAncerstors(request, constraint);
};
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
};
BindingWhenSyntax.prototype.whenNoAncestorMatches = function (constraint) {
this._binding.constraint = function (request) {
return !constraint_helpers_1.traverseAncerstors(request, constraint);
};
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
};
return BindingWhenSyntax;
}());
exports.BindingWhenSyntax = BindingWhenSyntax;
|