NightModel 0.3.0.1
dotnet add package NightModel --version 0.3.0.1
NuGet\Install-Package NightModel -Version 0.3.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="NightModel" Version="0.3.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NightModel --version 0.3.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: NightModel, 0.3.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 NightModel as a Cake Addin
#addin nuget:?package=NightModel&version=0.3.0.1
// Install NightModel as a Cake Tool
#tool nuget:?package=NightModel&version=0.3.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
NightModel
Простейший фреймворк для базовой реализации MVVM-паттерна.
Далее базовый пример реализации модели представления:
public class UserViewModel : RelayViewModel
{
#region Внедрение зависимостей
private readonly IErrorMessage _errorMessage;
#endregion Внедрение зависимостей
#region Поля для свойств
private string _userFirstName;
private string _userLastName;
private int _userAge;
private Guid _userId;
#endregion Поля для свойств
#region Свойства модели
public string UserFirstName { get => _userFirstName; set => Set(ref _userFirstName, value, OnNameCheck, _errorMessage.GetError(nameof(UserFirstName)), nameof(UserFirstName)); }
public string UserLastName { get => _userLastName; set => Set(ref _userLastName, value, OnNameCheck, _errorMessage.GetError(nameof(UserLastName)), nameof(UserLastName)); }
public int UserAge { get => _userAge; set => Set(ref _userAge, value, OnAgeCheck, _errorMessage.GetError(nameof(UserAge)), nameof(UserAge)); }
public Guid UserId {get => _userId; set => Set(ref _userId, value); }
#endregion Свойства модели
#region Команды
public ICommand SaveUserCommand { get; }
public ICommand LoadUserCommand { get; }
public ICommand AddNewUserCommand { get; }
public ICommand EditUserCommand { get; }
#endregion Команды
#region Конструктор
public UserViewModel(IErrorMessage errorMessage)
{
_errorMessage = errorMessage;
_userFirstName = "Иван";
_userLastName = "Петров";
_userAge = 20;
_userId = Guid.NewGuid();
SaveUserCommand = new RelayAsyncCommand<string>(OnSaveUserExecute, (pathSave) => !HasErrors && !string.IsNullOrWhiteSpace(pathSave));
LoadUserCommand = new RelayAsyncCommand(OnLoadUserExecute);
AddNewUserCommand = new RelayCommand(OnAddNewUserExecute);
EditUserCommand = new RelayCommand<UserViewModel>(OnEditUserExecute, (user) => user is not null);
}
#endregion Конструктор
#region Предикаты валидации
private static bool OnNameCheck(string name)
=> string.IsNullOrWhiteSpace(name) && name.Length < 5;
private static bool OnAgeCheck(int age)
=> age < 1 && age > 100;
#endregion Предикаты валидации
#region Обработчики команд
private Task OnSaveUserExecute(string? pathSave)
{
// Ваша реализация
throw new NotImplementedException(nameof(OnSaveUserExecute));
}
private Task OnLoadUserExecute()
{
// Ваша реализация
throw new NotImplementedException(nameof(OnLoadUserExecute));
}
private void OnAddNewUserExecute()
{
// Ваша реализация
throw new NotImplementedException(nameof(OnAddNewUserExecute));
}
private void OnEditUserExecute(UserViewModel? user)
{
// Ваша реализация
throw new NotImplementedException(nameof(OnEditUserExecute));
}
#endregion Обработчики команд
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0-windows7.0 is compatible. 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-windows7.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.
Version | Downloads | Last updated | |
---|---|---|---|
0.3.0.1 | 197 | 3/17/2023 | |
0.3.0 | 199 | 3/17/2023 | |
0.2.2 | 229 | 3/4/2023 | |
0.2.1 | 209 | 3/2/2023 | |
0.2.0 | 330 | 11/29/2022 | |
0.1.9 | 318 | 11/16/2022 | |
0.1.8 | 346 | 11/9/2022 | |
0.1.7 | 365 | 11/6/2022 | |
0.1.6 | 358 | 11/4/2022 | |
0.1.5 | 347 | 11/4/2022 | |
0.1.4 | 346 | 11/4/2022 | |
0.1.3 | 398 | 10/20/2022 | |
0.1.2 | 392 | 10/18/2022 | |
0.1.1 | 389 | 10/18/2022 | |
0.1.0 | 393 | 10/17/2022 |