service-model
Version:
An object oriented web service framework inspired by Windows Communication Foundation.
25 lines (24 loc) • 841 B
JavaScript
/**
* @hidden
*/
var RpcOperationSelector = (function () {
function RpcOperationSelector(endpoint) {
this._operations = new Map();
for (var i = 0; i < endpoint.operations.length; i++) {
var operation = endpoint.operations[i];
if (this._operations.has(operation.name)) {
throw new Error("There is already an operation with name '" + operation.name + "'.");
}
this._operations.set(operation.name, operation);
}
}
RpcOperationSelector.prototype.selectOperation = function (message) {
var keys = Object.keys(message.body);
if (keys.length != 1) {
return null;
}
return this._operations.get(keys[0]);
};
return RpcOperationSelector;
})();
exports.RpcOperationSelector = RpcOperationSelector;