Dhahabi.ViewModel 1.0.5

dotnet add package Dhahabi.ViewModel --version 1.0.5
                    
NuGet\Install-Package Dhahabi.ViewModel -Version 1.0.5
                    
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="Dhahabi.ViewModel" Version="1.0.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Dhahabi.ViewModel" Version="1.0.5" />
                    
Directory.Packages.props
<PackageReference Include="Dhahabi.ViewModel" />
                    
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 Dhahabi.ViewModel --version 1.0.5
                    
#r "nuget: Dhahabi.ViewModel, 1.0.5"
                    
#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 Dhahabi.ViewModel@1.0.5
                    
#: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=Dhahabi.ViewModel&version=1.0.5
                    
Install as a Cake Addin
#tool nuget:?package=Dhahabi.ViewModel&version=1.0.5
                    
Install as a Cake Tool

Dhahabi.ViewModel

NuGet NuGet

Descripción

DhahabiViewModel es un generador de código para C# que simplifica la implementación de INotifyPropertyChanged en tus ViewModels. Utilizando un atributo personalizado, puedes reducir significativamente el código repetitivo al implementar esta interfaz.

Características

  • Genera automáticamente los métodos get y set para propiedades marcadas con el atributo [ObservablePropertyAttribute].
  • Implementa la interfaz INotifyPropertyChanged para notificaciones de cambio de propiedad.
  • Reduce la cantidad de código repetitivo en tus ViewModels.

Instalación

Puedes instalar el paquete desde NuGet:

dotnet add package Dhahabi.ViewModel

O utilizando el administrador de paquetes NuGet en Visual Studio.

Uso

Para utilizar DhahabiViewModel, sigue estos pasos:

  1. Agrega el atributo [ObservablePropertyAttribute] a las propiedades de tu clase ViewModel que deseas generar automáticamente:
using System.ComponentModel;

namespace MyNamespace
{
    public partial class MyViewModel
    {
        [ObservableProperty]
        public bool _isLoading;

        [ObservableProperty]
        private string _status;
    }
}
  1. El generador de código se encargará de implementar automáticamente los métodos get y set para las propiedades marcadas con el atributo [ObservablePropertyAttribute], así como la interfaz INotifyPropertyChanged.

Ejemplo

Antes de usar DhahabiViewModel

public class MyViewModel : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;

    private bool _isLoading;
    public bool IsLoading
    {
        get => _isLoading;
        set
        {
            if (_isLoading != value)
            {
                _isLoading = value;
                OnPropertyChanged(nameof(IsLoading));
            }
        }
    }

    private string _status;
    public string Status
    {
        get => _status;
        set
        {
            if (_status != value)
            {
                _status = value;
                OnPropertyChanged(nameof(Status));
            }
        }
    }

    protected void OnPropertyChanged(string propertyName)
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
    }
}

Después de usar DhahabiViewModel

namespace MyNamespace
{
    public partial class MyViewModel
    {
        [ObservableProperty]
        private bool _isLoading;

        [ObservableProperty]
        private string _status;
    }
}

El generador de código se encargará de implementar automáticamente la interfaz INotifyPropertyChanged y los métodos get y set para las propiedades.

Contribuciones

Si deseas contribuir al desarrollo de este paquete, ¡siéntete libre de hacerlo! Puedes clonar el repositorio, realizar cambios y abrir un pull request.

Licencia

Este proyecto está licenciado bajo la licencia MIT. Consulta el archivo LICENSE para más detalles.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.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
1.0.5 329 2/19/2025
1.0.4 150 1/17/2025
1.0.3 201 12/13/2024
1.0.2 170 12/13/2024