OperationResultBase.cs 809 B

1234567891011121314151617181920212223242526272829303132
  1. using System.Runtime.InteropServices;
  2. namespace WinSCP
  3. {
  4. [Guid("B4CC583A-B64E-4797-9967-0FCB2F07C977")]
  5. [ClassInterface(Constants.ClassInterface)]
  6. [ComVisible(true)]
  7. public class OperationResultBase
  8. {
  9. public SessionRemoteExceptionCollection Failures { get; private set; }
  10. public bool IsSuccess { get { return (Failures.Count == 0); } }
  11. internal OperationResultBase()
  12. {
  13. Failures = new SessionRemoteExceptionCollection();
  14. }
  15. public void Check()
  16. {
  17. if (!IsSuccess)
  18. {
  19. throw Failures[0];
  20. }
  21. }
  22. internal void AddFailure(SessionRemoteException failure)
  23. {
  24. Failures.InternalAdd(failure);
  25. }
  26. }
  27. }