pvWay.MethodResultWrapper.Core 2.0.1

.NET Core 3.1
dotnet add package pvWay.MethodResultWrapper.Core --version 2.0.1
NuGet\Install-Package pvWay.MethodResultWrapper.Core -Version 2.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="pvWay.MethodResultWrapper.Core" Version="2.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add pvWay.MethodResultWrapper.Core --version 2.0.1
#r "nuget: pvWay.MethodResultWrapper.Core, 2.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install pvWay.MethodResultWrapper.Core as a Cake Addin
#addin nuget:?package=pvWay.MethodResultWrapper.Core&version=2.0.1

// Install pvWay.MethodResultWrapper.Core as a Cake Tool
#tool nuget:?package=pvWay.MethodResultWrapper.Core&version=2.0.1

Method Result Wrapper Core by pvWay

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 verions 2.0.1 it is now possible to add notifications to an existing result


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; }

        void AddNotification(string message, SeverityEnum severity);
        void AddNotification(IMethodResultNotification notification);

        /// <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 with 3 built in implementations. (1) ConsoleLogger that writes logs onto the Console, (2) MuteLogger that can be used for unit testing and (3) PersistenceLogger that can be used for persiting rich log rows into a database, a file or any other persistence layer by injecting the appropriate LogWriter (see pvWay.MsSqlLogWriter.Core nuGet)

  • The ILoggerService provides both sync and async methods with serveral signatures including (1) simple message, (2) list of messages, (3) MethodResult object (see above) (4) Exception

  • Each log row is also qualified by a Severity level from Debug to Fatal and enables also some interesting meta data like (1) UserId, (2) CompanyId, (3) Topic (4) MachineName

  • The service will also capture MemberName, FilePath and LineNumber

Happy coding

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp3.1
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 3.1

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on pvWay.MethodResultWrapper.Core:

Package Downloads

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
2.0.1 455 9/22/2021
2.0.0 412 9/20/2020
1.0.1 767 6/3/2020
1.0.0 413 5/27/2020

it is now possible to add a notification to an existing result