In WCF how to let user decide which service to request when you ask for two values and have ability to perform different calculations with those values.
For example you ask for value1 and value 2. And user have a choice to perform addition, subtraction and multiplication with those values.
How can you achieve that?
[OperationContract]
int GetTwoValues(int value1, int value2);
public int addition(int value1, int value2){
return value1+value2;
}
public int subtraction(int value1, int value2){
return value1-value2;
}
How to do some logic like
if user.request="addition"{
do addition
}
else if user.request="subtraction"{
do subtraction
}
i know its not a code that i have written but just trying to have you get some understanding of what i am saying. Any help will really be appreciated.
Not quite sure I understand the question
would work as would something like
Not that either is without drawbacks of course, but both meet your criteria.
edit: your comment raises the obvious point that the switch case allows the user to possibly supply a value that doesn’t map.
Yes it does and I wouldn’t use strings, that was your example!
Possible ways round it?
enumto force the user to select from a pre defined listI think perhaps you need to explain more in your question about what you want to achieve.