diff options
Diffstat (limited to 'mcs/class/Mono.GetOptions/OptionAttribute.cs')
-rw-r--r-- | mcs/class/Mono.GetOptions/OptionAttribute.cs | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/mcs/class/Mono.GetOptions/OptionAttribute.cs b/mcs/class/Mono.GetOptions/OptionAttribute.cs new file mode 100644 index 00000000000..739d71f15bb --- /dev/null +++ b/mcs/class/Mono.GetOptions/OptionAttribute.cs @@ -0,0 +1,66 @@ +using System; + +namespace Mono.GetOptions +{ + + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method)] + public class OptionAttribute : Attribute + { + public string ShortDescription; + public char ShortForm; + public string LongForm; + public int MaxOccurs; // negative means there is no limit + + private void SetValues( + string shortDescription, + char shortForm, + string longForm, + int maxOccurs) + { + ShortDescription = shortDescription; + ShortForm = shortForm; + LongForm = longForm; + MaxOccurs = maxOccurs; + } + + public OptionAttribute(string shortDescription) + { + SetValues(shortDescription, ' ', string.Empty, 0); + } + + public OptionAttribute(string shortDescription, char shortForm) + { + SetValues(shortDescription, shortForm, string.Empty, 0); + } + + public OptionAttribute(string shortDescription, char shortForm, string longForm) + { + SetValues(shortDescription, shortForm, longForm, 0); + } + + public OptionAttribute(string shortDescription, string longForm) + { + SetValues(shortDescription, ' ', longForm, 0); + } + + public OptionAttribute(int maxOccurs, string shortDescription) + { + SetValues(shortDescription, ' ', string.Empty, maxOccurs); + } + + public OptionAttribute(int maxOccurs, string shortDescription, char shortForm) + { + SetValues(shortDescription, shortForm, string.Empty, maxOccurs); + } + + public OptionAttribute(int maxOccurs, string shortDescription, char shortForm, string longForm) + { + SetValues(shortDescription, shortForm, longForm, maxOccurs); + } + + public OptionAttribute(int maxOccurs, string shortDescription, string longForm) + { + SetValues(shortDescription, ' ', longForm, maxOccurs); + } + } +} |