BadScript 2
Loading...
Searching...
No Matches
BaseAttribute.cs
Go to the documentation of this file.
1// Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information.
2
3using System;
4
6
7namespace CommandLine
8{
12 public abstract class BaseAttribute : Attribute
13 {
15 private int max;
16 private string metaValue;
17 private int min;
18 private Type resourceType;
19
23 protected internal BaseAttribute()
24 {
25 min = -1;
26 max = -1;
28 metaValue = string.Empty;
29 resourceType = null;
30 }
31
35 public bool Required { get; set; }
36
42 public int Min
43 {
44 get => min;
45 set
46 {
47 if (value < 0)
48 {
49 throw new ArgumentNullException("value");
50 }
51
52 min = value;
53 }
54 }
55
61 public int Max
62 {
63 get => max;
64 set
65 {
66 if (value < 0)
67 {
68 throw new ArgumentNullException("value");
69 }
70
71 max = value;
72 }
73 }
74
78 public object Default { get; set; }
79
83 public string HelpText
84 {
85 get => helpText.Value ?? string.Empty;
86 set => helpText.Value = value ?? throw new ArgumentNullException("value");
87 }
88
92 public string MetaValue
93 {
94 get => metaValue;
95 set
96 {
97 if (value == null)
98 {
99 throw new ArgumentNullException("value");
100 }
101
102 metaValue = value;
103 }
104 }
105
109 public bool Hidden { get; set; }
110
114 public Type ResourceType
115 {
116 get => resourceType;
117 set => resourceType =
118 helpText.ResourceType = value;
119 }
120 }
121}
Models a base attribute to define command line syntax.
int Min
When applied to System.Collections.Generic.IEnumerable<T> properties defines the lower range of items...
bool Required
Gets or sets a value indicating whether a command line option is required.
BaseAttribute()
Initializes a new instance of the CommandLine.BaseAttribute class.
readonly LocalizableAttributeProperty helpText
string MetaValue
Gets or sets mapped property meta value. Usually an uppercase hint of required value type.
Type ResourceType
Gets or sets the System.Type that contains the resources for HelpText.
bool Hidden
Gets or sets a value indicating whether a command line option is visible in the help text.
int Max
When applied to System.Collections.Generic.IEnumerable<T> properties defines the upper range of items...
string HelpText
Gets or sets a short description of this command line option. Usually a sentence summary.
object Default
Gets or sets mapped property default value.