using System;
using System.Reflection;
public class CommandLineSwitchAliasAttribute : Attribute
{
public CommandLineSwitchAliasAttribute(string alias)
{
Alias = alias;
}
public string Alias
{
get { return _Alias; }
set { _Alias = value; }
}
private string _Alias;
}
class CommandLineInfo
{
[CommandLineSwitchAliasAttribute("?")]
public bool Help
{
get { return _Help; }
set { _Help = value; }
}
private bool _Help;
}
class MainClass
{
static void Main()
{
PropertyInfo property = typeof(CommandLineInfo).GetProperty("Help");
CommandLineSwitchAliasAttribute attribute = (CommandLineSwitchAliasAttribute)property.GetCustomAttributes(typeof(CommandLineSwitchAliasAttribute), false)[0];
if (attribute.Alias == "?")
{
Console.WriteLine("Help(?)");
};
}
}
|