Files
speckle-sharp-connectors/DUI3/Speckle.Connectors.DUI/Bridge/Result.cs
T
Adam Hathcock 891a18819b React to sdk renaming (#113)
* react to renamespacing

* merge dev

* fmt

* initialize things with typeloader

* autocad initialization

* add arcgis

* add more projects to local

* instrument rhino more

* update nugets

* fmt
2024-08-08 10:32:01 +00:00

59 lines
1.4 KiB
C#

using System.Diagnostics.CodeAnalysis;
using Speckle.Sdk.Common;
namespace Speckle.Connectors.DUI.Bridge;
/// <summary>
/// Result Pattern struct
/// </summary>
/// <typeparam name="T"></typeparam>
[ExcludeFromCodeCoverage]
public readonly struct Result<T>
{
//Don't add new members to this struct, it is perfect.
public T? Value { get; }
public Exception? Exception { get; }
[MemberNotNullWhen(false, nameof(Exception))]
public bool IsSuccess => Exception is null;
/// <summary>
/// Create a successful result
/// </summary>
/// <param name="result"></param>
public Result(T result)
{
Value = result;
}
/// <summary>
/// Create a non-successful result
/// </summary>
/// <param name="result"></param>
/// <exception cref="ArgumentNullException"><paramref name="result"/> was null</exception>
public Result([NotNull] Exception? result)
{
Exception = result.NotNull();
}
}
[ExcludeFromCodeCoverage]
public readonly struct Result
{
//Don't add new members to this struct, it is perfect.
public Exception? Exception { get; }
[MemberNotNullWhen(false, nameof(Exception))]
public bool IsSuccess => Exception is null;
/// <summary>
/// Create a non-successful result
/// </summary>
/// <param name="result"></param>
/// <exception cref="ArgumentNullException"><paramref name="result"/> was null</exception>
public Result([NotNull] Exception? result)
{
Exception = result.NotNull();
}
}