15815213711
2024-08-26 67b8b6731811983447e053d4396b3708c14dfe3c
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
import { getServiceIdentifierAsString } from "../inversify";
import * as ERROR_MSGS from "../constants/error_msgs";
import { BindingTypeEnum } from "../constants/literal_types";
import { FactoryType } from "./factory_type";
export var multiBindToService = function (container) {
    return function (service) {
        return function () {
            var types = [];
            for (var _i = 0; _i < arguments.length; _i++) {
                types[_i] = arguments[_i];
            }
            return types.forEach(function (t) { return container.bind(t).toService(service); });
        };
    };
};
export var ensureFullyBound = function (binding) {
    var boundValue = null;
    switch (binding.type) {
        case BindingTypeEnum.ConstantValue:
        case BindingTypeEnum.Function:
            boundValue = binding.cache;
            break;
        case BindingTypeEnum.Constructor:
        case BindingTypeEnum.Instance:
            boundValue = binding.implementationType;
            break;
        case BindingTypeEnum.DynamicValue:
            boundValue = binding.dynamicValue;
            break;
        case BindingTypeEnum.Provider:
            boundValue = binding.provider;
            break;
        case BindingTypeEnum.Factory:
            boundValue = binding.factory;
            break;
    }
    if (boundValue === null) {
        var serviceIdentifierAsString = getServiceIdentifierAsString(binding.serviceIdentifier);
        throw new Error(ERROR_MSGS.INVALID_BINDING_TYPE + " " + serviceIdentifierAsString);
    }
};
export var getFactoryDetails = function (binding) {
    switch (binding.type) {
        case BindingTypeEnum.Factory:
            return { factory: binding.factory, factoryType: FactoryType.Factory };
        case BindingTypeEnum.Provider:
            return { factory: binding.provider, factoryType: FactoryType.Provider };
        case BindingTypeEnum.DynamicValue:
            return { factory: binding.dynamicValue, factoryType: FactoryType.DynamicValue };
        default:
            throw new Error("Unexpected factory type " + binding.type);
    }
};
//# sourceMappingURL=binding_utils.js.map