ServiceResult.cs 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // -
  2. // <copyright file="ServiceResult.cs" company="Microsoft Corporation">
  3. // Copyright (c) Microsoft Corporation. All rights reserved.
  4. // </copyright>
  5. // -
  6. namespace Microsoft.Hawaii
  7. {
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Net;
  11. /// <summary>
  12. /// A base class for all Hawaii service result classes.
  13. /// Various Hawaii service result classes will represent the result corresponding to different type of Hawaii service calls.
  14. /// This class contains functionality common to all Hawaii service result classes.
  15. /// </summary>
  16. public abstract class ServiceResult
  17. {
  18. /// <summary>
  19. /// Initializes a new instance of the ServiceResult class.
  20. /// </summary>
  21. public ServiceResult() :
  22. this(null, Status.Unspecified, null)
  23. {
  24. }
  25. /// <summary>
  26. /// Initializes a new instance of the ServiceResult class.
  27. /// </summary>
  28. /// <param name="stateObject">Specifies a user-defined object.</param>
  29. public ServiceResult(object stateObject) :
  30. this(stateObject, Status.Unspecified, null)
  31. {
  32. }
  33. /// <summary>
  34. /// Initializes a new instance of the ServiceResult class.
  35. /// </summary>
  36. /// <param name="stateObject">Specifies a user-defined object.</param>
  37. /// <param name="status">Specifies the status of the service call.</param>
  38. public ServiceResult(object stateObject, Status status) :
  39. this(stateObject, status, null)
  40. {
  41. }
  42. /// <summary>
  43. /// Initializes a new instance of the ServiceResult class.
  44. /// </summary>
  45. /// <param name="stateObject">Specifies a user-defined object.</param>
  46. /// <param name="status">Specifies the status of the service call.</param>
  47. /// <param name="exception">An exception instance used if an error occured during the service call.</param>
  48. public ServiceResult(object stateObject, Status status, Exception exception)
  49. {
  50. this.Status = status;
  51. this.Exception = exception;
  52. this.StateObject = stateObject;
  53. }
  54. /// <summary>
  55. /// Gets or sets the error exception.
  56. /// </summary>
  57. public Exception Exception { get; set; }
  58. /// <summary>
  59. /// Gets or sets the status of the service call.
  60. /// </summary>
  61. public Status Status { get; set; }
  62. /// <summary>
  63. /// Gets or sets the Service-generated RequestId. Used for debugging
  64. /// </summary>
  65. public Guid RequestId { get; set; }
  66. /// <summary>
  67. /// Gets or sets the Service-side exceptions. Used for debugging
  68. /// </summary>
  69. public IEnumerable<LoggedException> ServerExceptionStack { get; set; }
  70. /// <summary>
  71. /// Gets or sets a user-defined object.
  72. /// </summary>
  73. public object StateObject { get; set; }
  74. }
  75. }