You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

ServiceResult.cs 865 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. namespace LLama.Web.Common
  2. {
  3. public class ServiceResult<T> : ServiceResult, IServiceResult<T>
  4. {
  5. public T Value { get; set; }
  6. }
  7. public class ServiceResult
  8. {
  9. public string Error { get; set; }
  10. public bool HasError
  11. {
  12. get { return !string.IsNullOrEmpty(Error); }
  13. }
  14. public static IServiceResult<T> FromValue<T>(T value)
  15. {
  16. return new ServiceResult<T>
  17. {
  18. Value = value,
  19. };
  20. }
  21. public static IServiceResult<T> FromError<T>(string error)
  22. {
  23. return new ServiceResult<T>
  24. {
  25. Error = error,
  26. };
  27. }
  28. }
  29. public interface IServiceResult<T>
  30. {
  31. T Value { get; set; }
  32. string Error { get; set; }
  33. bool HasError { get; }
  34. }
  35. }