1
0
mirror of https://github.com/winscp/winscp.git synced 2026-10-24 02:28:55 +03:00
Files
winscp/dotnet/OperationResultBase.cs
Michael Kent 531bbb770a Issue 856 – Define and implement interface for the .NET library
https://winscp.net/tracker/856
----
@mjkent: Add interfaces to .NET assembly for improved testability
This PR extracts interfaces from the main WinSCP .NET assembly classes (Session, SessionOptions, TransferOptions, etc.), enabling:

Unit testing - Mock ISession to test code that uses WinSCP without requiring actual SFTP/FTP connections
Dependency injection - Register interfaces in DI containers for cleaner architecture
Decoupling - Program against abstractions rather than concrete implementations
This change should be non-breaking, but I'm new to this project so review and feedback appreciated!
2025-12-11 15:15:29 +01:00

33 lines
832 B
C#

using System.Runtime.InteropServices;
namespace WinSCP
{
[Guid("B4CC583A-B64E-4797-9967-0FCB2F07C977")]
[ClassInterface(Constants.ClassInterface)]
[ComVisible(true)]
public class OperationResultBase : IOperationResultBase
{
public SessionRemoteExceptionCollection Failures { get; private set; }
public bool IsSuccess { get { return (Failures.Count == 0); } }
internal OperationResultBase()
{
Failures = new SessionRemoteExceptionCollection();
}
public void Check()
{
if (!IsSuccess)
{
throw Failures[0];
}
}
internal void AddFailure(SessionRemoteException failure)
{
Failures.InternalAdd(failure);
}
}
}