If return object
from your service layer, you have to cast the returnobject
appropriate type/value in the client code. Therefore, type checking defferred to runtime which leads invalidcastexceptions if you are not careful. More importantly it is an inelegant solution which will pollute your code and therefore reduce understandability of your code.
If you want to have only one type you could use generics:
public class ServiceResult<T>
{
public IEnumberable<ValidationResult> ValidationResults { get; set; }
public T ResultObject
{
get;set;
}
}
If you do not like this solution, you could define a result type type for each service method.
public class ResultBase
{
public IEnumerable<ValidationResult> ValidationResults { get; set; }
}
public class RegisterResult : ResultBase
{
public Video Video{get;set;}
}