Seenginx/Seenginx.Models/Result.cs

27 lines
610 B
C#
Raw Normal View History

2020-04-12 20:01:46 +02:00
using System;
using System.Collections.Generic;
using System.Text;
namespace Seenginx.Models
{
public class Result<D>
{
public bool AllOk { get; private set; } = true;
public string ErrorMessage { get; private set; }
public Exception Exception { get; private set; } = null;
public D Data { get; private set; }
public Result<D> Invalidate(string errorMessage, Exception exception = null)
{
AllOk = false;
ErrorMessage = errorMessage;
if (exception != null)
Exception = exception;
return this;
}
public void SetData(D data) => Data = data;
}
}