MethodResultWrapper 3.0.3
See the version list below for details.
dotnet add package MethodResultWrapper --version 3.0.3
NuGet\Install-Package MethodResultWrapper -Version 3.0.3
<PackageReference Include="MethodResultWrapper" Version="3.0.3" />
paket add MethodResultWrapper --version 3.0.3
#r "nuget: MethodResultWrapper, 3.0.3"
// Install MethodResultWrapper as a Cake Addin #addin nuget:?package=MethodResultWrapper&version=3.0.3 // Install MethodResultWrapper as a Cake Tool #tool nuget:?package=MethodResultWrapper&version=3.0.3
Method Result Wrapper
Provides a generic wrapper that returns whether or not a method succeeded or failed carrying the method result on success or a list of notifications in case of failure. As of version 3.0.0 The package includes the DsoHttpResult<T> object that enables to standardize response from Web API. See interface here after.
Interfaces
MethodResult interfaces
public interface IMethodResult
{
/// <summary>
/// At least one notification has a severity
/// greater or equal to Error
/// </summary>
bool Failure { get; }
/// <summary>
/// No notification or all notifications severity
/// are lower than Error
/// </summary>
bool Success { get; }
SeverityEnum Severity { get; }
/// <summary>
/// Bulk string made of the concatenation
/// of the notifications separated by new
/// lines
/// </summary>
string ErrorMessage { get; }
IEnumerable<IMethodResultNotification> Notifications { get; }
/// <summary>
/// Will throw new Exception(ErrorMessage)
/// </summary>
void Throw();
}
public interface IMethodResult<out T> : IMethodResult
{
T Data { get; }
}
public interface IMethodResultNotification
{
SeverityEnum Severity { get; }
string Message { get; }
}
ILoggerService interface
This nuget package also provides the ILoggerService interface and a ConsoleLogger concrete that supports the MethodResult object
Remark: feel free to get the MsSqlLoggerService nuget package that implements this interface enabling to persist logs into a table of your choice in a Ms Sql database
/// <summary>
/// Subsequent calls to the Log method will
/// store the provided UserId and CompanyId
/// into their corresponding columns
/// </summary>
/// <param name="userId"></param>
/// <param name="companyId"></param>
void SetUser(string userId, string companyId = null);
/// <summary>
/// Topic is an optional extra column in the log
/// that enables grouping logs. Subsequent calls to
/// the Log method will store the provided
/// topic into the corresponding column
/// </summary>
/// <param name="topic"></param>
void SetTopic(string topic);
// TOPIC LESS METHODS
void Log(
string message,
SeverityEnum severity = SeverityEnum.Debug,
[CallerMemberName] string memberName = "",
[CallerFilePath] string filePath = "",
[CallerLineNumber] int lineNumber = -1);
void Log(
IEnumerable<string> messages,
SeverityEnum severity,
[CallerMemberName] string memberName = "",
[CallerFilePath] string filePath = "",
[CallerLineNumber] int lineNumber = -1);
void Log(
IMethodResult result,
[CallerMemberName] string memberName = "",
[CallerFilePath] string filePath = "",
[CallerLineNumber] int lineNumber = -1);
void Log(
Exception e,
SeverityEnum severity = SeverityEnum.Fatal,
[CallerMemberName] string memberName = "",
[CallerFilePath] string filePath = "",
[CallerLineNumber] int lineNumber = -1);
// TOPIC METHODS
void Log(
string message,
string topic,
SeverityEnum severity = SeverityEnum.Debug,
[CallerMemberName] string memberName = "",
[CallerFilePath] string filePath = "",
[CallerLineNumber] int lineNumber = -1);
void Log(
IEnumerable<string> messages,
string topic,
SeverityEnum severity,
[CallerMemberName] string memberName = "",
[CallerFilePath] string filePath = "",
[CallerLineNumber] int lineNumber = -1);
void Log(
IMethodResult result,
string topic,
[CallerMemberName] string memberName = "",
[CallerFilePath] string filePath = "",
[CallerLineNumber] int lineNumber = -1);
void Log(
Exception e,
string topic,
SeverityEnum severity = SeverityEnum.Fatal,
[CallerMemberName] string memberName = "",
[CallerFilePath] string filePath = "",
[CallerLineNumber] int lineNumber = -1);
DsoHttpResult
public interface IDsoHttpResult
{
/// <summary>
/// Status O (ok) W (warning) E (error) F (fatal)...
/// </summary>
string StatusCode { get; }
/// <summary>
/// The mutation performed if any N (none) C (create) U (update) D (delete)
/// </summary>
string MutationCode { get; }
/// <summary>
/// useful for paging
/// </summary>
bool HasMoreResults { get; }
IEnumerable<IDsoHttpResultNotification> Notifications { get; }
}
public interface IDsoHttpResult<out T>: IDsoHttpResult
{
T Data { get; }
}
public interface IDsoHttpResultNotification
{
string Message { get; }
/// <summary>
/// Severity O (ok) W (warning) E (error) F (fatal)...
/// </summary>
string SeverityCode { get; }
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
This package has no dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on MethodResultWrapper:
Package | Downloads |
---|---|
MsSqlLoggerService
Ms Sql implementation of MethodResultWrapper ILoggerService. Persists logs into a MsSql table. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
3.0.6 | 1,668 | 9/22/2021 | |
3.0.5 | 851 | 4/28/2021 | |
3.0.4 | 785 | 4/27/2021 | |
3.0.3 | 1,522 | 6/10/2020 | |
3.0.2 | 969 | 6/10/2020 | |
3.0.1 | 934 | 6/10/2020 | |
3.0.0 | 1,091 | 6/10/2020 | |
2.0.1 | 1,238 | 3/20/2020 | |
2.0.0 | 1,055 | 3/19/2020 | |
1.1.3 | 971 | 3/20/2020 | |
1.1.2 | 1,096 | 3/19/2020 | |
1.1.0 | 1,401 | 3/7/2020 | |
1.0.0 | 984 | 2/28/2020 |
MutationEnum made bijective