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.
<PackageVersion Include="NightModel" Version="0.3.0.1" />
                    
Directory.Packages.props
<PackageReference Include="NightModel" />
                    
Project file
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 NightModel --version 0.3.0.1
                    
#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.
#:package NightModel@0.3.0.1
                    
#: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=NightModel&version=0.3.0.1
                    
Install as a Cake Addin
#tool nuget:?package=NightModel&version=0.3.0.1
                    
Install as a Cake Tool

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 Compatible and additional computed target framework versions.
.NET net7.0-windows7.0 is compatible.  net8.0-windows was computed.  net9.0-windows 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.
  • 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.