2002-12-28 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
[mono.git] / mcs / class / Mono.GetOptions / OptionAttribute.cs
1 using System;
2
3 namespace Mono.GetOptions
4 {
5
6         [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method)]
7         public class OptionAttribute : Attribute
8         {
9                 public string ShortDescription;
10                 public char ShortForm;
11                 public string LongForm;
12                 public int MaxOccurs; // negative means there is no limit
13
14                 private void SetValues(
15                         string shortDescription, 
16                         char shortForm, 
17                         string longForm, 
18                         int maxOccurs)
19                 {
20                         ShortDescription = shortDescription; 
21                         ShortForm = shortForm;
22                         LongForm = longForm;
23                         MaxOccurs = maxOccurs;
24                 }
25
26                 public OptionAttribute(string shortDescription)
27                 {
28                         SetValues(shortDescription, ' ', string.Empty, 0); 
29                 }
30
31                 public OptionAttribute(string shortDescription, char shortForm)
32                 {
33                         SetValues(shortDescription, shortForm, string.Empty, 0);
34                 }
35
36                 public OptionAttribute(string shortDescription, char shortForm, string longForm)
37                 {
38                         SetValues(shortDescription, shortForm, longForm, 0); 
39                 }
40
41                 public OptionAttribute(string shortDescription, string longForm)
42                 {
43                         SetValues(shortDescription, ' ', longForm, 0); 
44                 }
45
46                 public OptionAttribute(int maxOccurs, string shortDescription)
47                 {
48                         SetValues(shortDescription, ' ', string.Empty, maxOccurs); 
49                 }
50
51                 public OptionAttribute(int maxOccurs, string shortDescription, char shortForm)
52                 {
53                         SetValues(shortDescription, shortForm, string.Empty, maxOccurs);
54                 }
55
56                 public OptionAttribute(int maxOccurs, string shortDescription, char shortForm, string longForm)
57                 {
58                         SetValues(shortDescription, shortForm, longForm, maxOccurs); 
59                 }
60
61                 public OptionAttribute(int maxOccurs, string shortDescription, string longForm)
62                 {
63                         SetValues(shortDescription, ' ', longForm, maxOccurs); 
64                 }
65         }
66 }