using System;
namespace Developpez.Dotnet.Windows.ViewModel
{
///
/// Classe de base pour les attributs servant à lier des méthodes à des commandes.
///
public abstract class CommandAttributeBase : Attribute
{
///
/// Initialise une nouvelle instance de CommandAttributeBase.
///
protected CommandAttributeBase()
{
}
///
/// Initialise une nouvelle instance de CommandAttributeBase avec le nom de commande spécifié.
///
/// Nom de la commande
protected CommandAttributeBase(string commandName)
{
_commandName = commandName;
}
private readonly string _commandName;
///
/// Nom de la commande.
///
/// Si cette propriété n'est pas spécifiée, le nom de commande utilisé sera XXXCommand (XXX étant le nom de la méthode).
public string CommandName
{
get { return _commandName; }
}
}
///
/// Indique qu'une méthode implémente l'exécution d'une commande
///
[AttributeUsage(AttributeTargets.Method)]
public class CommandExecuteAttribute : CommandAttributeBase
{
///
/// Initialise une nouvelle instance de CommandExecuteAttribute.
///
public CommandExecuteAttribute()
{
}
///
/// Initialise une nouvelle instance de CommandExecuteAttribute avec le nom de commande spécifié.
///
/// Nom de la commande
public CommandExecuteAttribute(string commandName)
: base(commandName)
{
}
}
///
/// Indique qu'une méthode vérifie si une commande peut s'exécuter
///
[AttributeUsage(AttributeTargets.Method)]
public class CommandCanExecuteAttribute : CommandAttributeBase
{
///
/// Initialise une nouvelle instance de CommandCanExecuteAttribute avec le nom de commande spécifié.
///
/// Nom de la commande
public CommandCanExecuteAttribute(string commandName)
: base(commandName)
{
}
}
}