HI all,
I am not sure whether this is possible in C# or in any other language for that matter. Below is my requirement
It is a service application which will get some commands to execute. Those commands are predefined (methods in classes). When user calls these methods, the application framework must call another method (a default method) and complete the execution then execute teh called method. I understand there is a possibility of performance but i am in need of this type of architecture.
To explain better below is an example
Step 1: User A calls a webservice method GetData (string dataid, string dataLocation).
step 2: webservice recieves this call as http get method and it must first execute a default method CheckData(GetData).
Step 3: CheckData will now check the data which was sent to GetData Method and then it executes the GetData Method.
This way i can perform some operations like authentication, cleanup works and also other various system activities. Will it be possible for this kind of model.
My requirement is
User calls Webservice method employee.GetQualification.
In webservices, the call stack must be
Validater.CheckData (GetQualification)
Employee.GetQualification()
Validator.CheckOutput(output)
I am not looking for something like below (method stack)
Employee.GetQualification()
Validater.CheckData (getQualification parameters)
execute actual execution
Validator.CheckOutput(output)
Return
Some links/ thoughts would be beneficial for me to start on
Thanks.
At the method level, there is no way to do exactly what you want, but if you’re using WCF, you can create a custom behavior that does this for you.
See this article for examples, particularly the bit about IParameterInspector.
Personally, I don’t think I would use this approach though, unless you need it to be configurable behavior. Hard coding a call to a single private method to do some validation at the start of some operation isn’t so bad.