BrandUp.Core
1.0.11
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 BrandUp.Core --version 1.0.11
NuGet\Install-Package BrandUp.Core -Version 1.0.11
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="BrandUp.Core" Version="1.0.11" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BrandUp.Core" Version="1.0.11" />
<PackageReference Include="BrandUp.Core" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BrandUp.Core --version 1.0.11
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: BrandUp.Core, 1.0.11"
#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.
#:package BrandUp.Core@1.0.11
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BrandUp.Core&version=1.0.11
#tool nuget:?package=BrandUp.Core&version=1.0.11
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
BrandUp.Core
Base framework for .NET development.
- Universal result structure
- CQRS infrastructure
Qieries
public class UserByPhoneQuery : IQuery<User>
{
[Required]
public string Phone { get; set; }
}
public class UserByPhoneQueryHandler : IQueryHandler<UserByPhoneQuery, User>
{
public Task<IList<User>> HandleAsync(UserByPhoneQuery query, CancellationToken cancellationToken = default)
{
var result = new List<User>
{
new User
{
Id = System.Guid.NewGuid(),
Phone = query.Phone
}
};
return Task.FromResult<IList<User>>(result);
}
}
serviceCollection.AddDomain(options =>
{
options.AddQuery<UserByPhoneQuery>();
})
.AddValidator<ComponentModelValidator>();
var userByPhoneResult = await domain.ReadAsync(new UserByPhoneQuery { Phone = "89232229022" });
// userByPhoneResult.IsSuccess
// userByPhoneResult.Errors
// userByPhoneResult.Data
// userByPhoneResult.Data[0]
Commands
public class SignUpCommandHandler : ICommandHandler<SignUpCommand, SignUpResult>
{
readonly IUserRepository userRepository;
public SignUpCommandHandler(IUserRepository userRepository)
{
this.userRepository = userRepository ?? throw new ArgumentNullException(nameof(userRepository));
}
public async Task<SignUpResult> HandleAsync(SignUpCommand command, CancellationToken cancellationToken = default)
{
var user = new User
{
Id = System.Guid.NewGuid(),
Phone = command.Phone
};
await userRepository.CreateAsync(user, cancellationToken);
var result = new SignUpResult
{
User = user
};
return result;
}
}
public class SignUpCommand : ICommand<SignUpResult>
{
[Required]
public string Phone { get; set; }
}
public class SignUpResult
{
public User User { get; set; }
}
serviceCollection.AddDomain(options =>
{
options.AddCommand<SignUpCommandHandler>();
options.AddCommand<VisitUserCommandHandler>();
options.AddCommand<ChangeUserPhoneCommandHandler>();
})
.AddValidator<ComponentModelValidator>();
var domain = serviceProvider.GetRequiredService<IDomain>();
var signUpResult = await domain.SendAsync(new Example.Commands.SignUpCommandHandler { Phone = "+79231145449" });
// signUpResult.IsSuccess
// signUpResult.Errors
// signUpResult.Data
Items
public class User : IItem<Guid>
{
public Guid Id { get; set; }
public string Phone { get; set; }
}
public class UserProvider : IItemProvider<Guid, User>
{
public Task<User> FindByIdASync(Guid itemId, CancellationToken cancellationToken = default)
{
return Task.FromResult(new User { Id = new Guid("0b1eb946-c07c-406c-a7ba-d56b007c830a"), Phone = "79232229022" });
}
}
public class VisitUserCommand : IItemCommand<Items.User> { }
public class VisitUserCommandHandler : IItemCommandHandler<Items.User, VisitUserCommand>
{
public Task<Result> HandleAsync(Items.User item, VisitUserCommand command, CancellationToken cancellationToken = default)
{
return Task.FromResult(Result.Success());
}
}
serviceCollection.AddDomain(options =>
{
options.AddCommand<Example.Commands.VisitUserCommandHandler>();
})
.AddItemProvider<UserProvider>();
var domain = serviceProvider.GetRequiredService<IDomain>();
var item = await domain.FindItem<Guid, User>(new Guid("0b1eb946-c07c-406c-a7ba-d56b007c830a"));
var userProvider1 = serviceProvider.GetService<UserProvider>();
var userProvider2 = serviceProvider.GetService<IItemProvider<Guid, User>>();
var result = await domain.SendItemAsync(new Guid("0b1eb946-c07c-406c-a7ba-d56b007c830a"), new Example.Commands.VisitUserCommand());
var result = await domain.SendItemAsync(item, new Example.Commands.VisitUserCommand());
Results
Result.Success()
Result.Success<TData>(data)
Result.Error("code", "message")
Result.Error<TData>("code", "message")
Result.Error(...errors)
Result.Error<TData>(...errors)
// result.IsSuccess
// result.Errors
// result.Data
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
2.0.5 | 186 | 7/1/2025 |
2.0.4 | 339 | 6/10/2025 |
2.0.3 | 197 | 3/29/2025 |
2.0.2 | 226 | 3/9/2025 |
2.0.1 | 180 | 12/15/2024 |
1.2.1 | 196 | 7/9/2024 |
1.1.3 | 223 | 4/29/2024 |
1.1.1 | 147 | 4/29/2024 |
1.0.11 | 307 | 1/20/2024 |
1.0.10 | 731 | 2/13/2023 |
1.0.8 | 773 | 7/7/2022 |
1.0.6 | 538 | 4/21/2022 |
1.0.5 | 526 | 3/26/2022 |
1.0.4 | 526 | 3/12/2022 |
1.0.3 | 524 | 3/12/2022 |
1.0.2 | 537 | 3/10/2022 |
1.0.1 | 509 | 3/9/2022 |