Gleeman.EffectiveResult
7.0.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Gleeman.EffectiveResult --version 7.0.0
NuGet\Install-Package Gleeman.EffectiveResult -Version 7.0.0
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="Gleeman.EffectiveResult" Version="7.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Gleeman.EffectiveResult --version 7.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Gleeman.EffectiveResult, 7.0.0"
#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 Gleeman.EffectiveResult as a Cake Addin #addin nuget:?package=Gleeman.EffectiveResult&version=7.0.0 // Install Gleeman.EffectiveResult as a Cake Tool #tool nuget:?package=Gleeman.EffectiveResult&version=7.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Effective Result
dotnet
CLI
$ dotnet add package Gleeman.EffectiveResult --version 7.0.0
Result<T> Ok(T value = null, IEnumerable<T> values = null, string message = null)
Result<T> Fail(string errorMessage = null, IEnumerable<string> errorMessages = null)
Result Ok(string message = null)
Result Fail(string errorMessage = null, IEnumerable<string> errorMessages = null)
USAGE
public class User
{
private static List<User> _users = new();
public string FirstName { get; private set; }
public string LastName { get; private set; }
public string Email { get; private set; }
public User()
{
_users.AddRange(new List<User>
{
new User
{
FirstName = "Abc",
LastName = "ABC",
Email = "abc@mail.com"
},
new User
{
FirstName = "Cde",
LastName = "CDE",
Email = "cde@mail.com"
},
new User
{
FirstName = "Fgh",
LastName = "FGH",
Email = "fgh@mail.com"
}
});
}
public static Result<User> CreateUser(string firstName, string lastName, string email)
{
var errors = new List<string>();
if (string.IsNullOrEmpty(firstName)) errors.Add("First name cannont be empty!");
if (string.IsNullOrEmpty(lastName)) errors.Add("Last name cannont be empty!");
if (string.IsNullOrEmpty(email)) errors.Add("Email cannot be empty!");
if (errors.Count > 0)
return Result<User>.Fail(errorMessages: errors);
User user = new()
{
FirstName = firstName,
LastName = lastName,
Email = email
};
_users.Add(user);
return Result<User>.Ok(user);
}
public static Result ChangeEmail(string email)
{
if (string.IsNullOrEmpty(email))
return Result.Fail("Email cannot be empty!");
return Result.Ok();
}
public static Result<User> GetUsers() => Result<User>.Ok(values: _users);
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net7.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.