S
Shapper
Hello,
I have the following code which I repeat in many places:
FindUserByIdResponse response = disp.FindUserById(id);
if (response.Exception == null) {
if (response.User == null)
return new StMessage("NotFound");
} else
return new StMessage("Error");
Response can be a FindUserByIdResponse, FindPostByIdResponse, ...
Each response implements IRequestResponse and as a property:
- FindUserByIdResponse has the property User;
- FindPostByIdResponse has the property Post;
I would like to move the previous validation to another class:
Message msg = ValidateResponse<FindUserByIdResponse.User>(response);
In this case the response would be tested against null.
And its property of type User would also be tested against null.
Is this possible?
I have the following code which I repeat in many places:
FindUserByIdResponse response = disp.FindUserById(id);
if (response.Exception == null) {
if (response.User == null)
return new StMessage("NotFound");
} else
return new StMessage("Error");
Response can be a FindUserByIdResponse, FindPostByIdResponse, ...
Each response implements IRequestResponse and as a property:
- FindUserByIdResponse has the property User;
- FindPostByIdResponse has the property Post;
I would like to move the previous validation to another class:
Message msg = ValidateResponse<FindUserByIdResponse.User>(response);
In this case the response would be tested against null.
And its property of type User would also be tested against null.
Is this possible?