BadScript 2
Loading...
Searching...
No Matches
CommandLine.Core.Specification Class Referenceabstract
Inheritance diagram for CommandLine.Core.Specification:
CommandLine.Core.OptionSpecification CommandLine.Core.ValueSpecification

Static Public Member Functions

static Specification FromProperty (PropertyInfo property)
 

Protected Member Functions

 Specification (SpecificationType tag, bool required, Maybe< int > min, Maybe< int > max, Maybe< object > defaultValue, string helpText, string metaValue, IEnumerable< string > enumValues, Type conversionType, TargetType targetType, bool hidden=false)
 

Properties

SpecificationType Tag [get]
 
bool Required [get]
 
Maybe< int > Min [get]
 
Maybe< int > Max [get]
 
Maybe< object > DefaultValue [get]
 
string HelpText [get]
 
string MetaValue [get]
 
IEnumerable< string > EnumValues [get]
 
Type ConversionType [get]
 This information is denormalized to decouple Specification from PropertyInfo.
 
TargetType TargetType [get]
 
bool Hidden [get]
 

Detailed Description

Definition at line 27 of file Specification.cs.

Constructor & Destructor Documentation

◆ Specification()

CommandLine.Core.Specification.Specification ( SpecificationType  tag,
bool  required,
Maybe< int >  min,
Maybe< int >  max,
Maybe< object >  defaultValue,
string  helpText,
string  metaValue,
IEnumerable< string >  enumValues,
Type  conversionType,
TargetType  targetType,
bool  hidden = false 
)
protected

Definition at line 29 of file Specification.cs.

40 {
41 Tag = tag;
42 Required = required;
43 Min = min;
44 Max = max;
45 DefaultValue = defaultValue;
46 ConversionType = conversionType;
47 TargetType = targetType;
48 HelpText = helpText;
49 MetaValue = metaValue;
50 EnumValues = enumValues;
51 Hidden = hidden;
52 }
Type ConversionType
This information is denormalized to decouple Specification from PropertyInfo.
IEnumerable< string > EnumValues

Member Function Documentation

◆ FromProperty()

static Specification CommandLine.Core.Specification.FromProperty ( PropertyInfo  property)
static

Definition at line 77 of file Specification.cs.

78 {
79 object[] attrs = property.GetCustomAttributes(true);
80 IEnumerable<OptionAttribute> oa = attrs.OfType<OptionAttribute>();
81
82 if (oa.Count() == 1)
83 {
84 OptionSpecification spec = OptionSpecification.FromAttribute(oa.Single(),
85 property.PropertyType,
87 .GetNamesOfEnum(property.PropertyType)
88 );
89
90 if (spec.ShortName.Length == 0 && spec.LongName.Length == 0)
91 {
92 return spec.WithLongName(property.Name.ToLowerInvariant());
93 }
94
95 return spec;
96 }
97
98 IEnumerable<ValueAttribute> va = attrs.OfType<ValueAttribute>();
99
100 if (va.Count() == 1)
101 {
102 return ValueSpecification.FromAttribute(va.Single(),
103 property.PropertyType,
104 property.PropertyType.GetTypeInfo()
105 .IsEnum
106 ? Enum.GetNames(property.PropertyType)
107 : Enumerable.Empty<string>()
108 );
109 }
110
111 throw new InvalidOperationException();
112 }
static IEnumerable< string > GetNamesOfEnum(Type t)

Property Documentation

◆ ConversionType

Type CommandLine.Core.Specification.ConversionType
get

This information is denormalized to decouple Specification from PropertyInfo.

Definition at line 71 of file Specification.cs.

71{ get; }

◆ DefaultValue

Maybe<object> CommandLine.Core.Specification.DefaultValue
get

Definition at line 62 of file Specification.cs.

62{ get; }

◆ EnumValues

IEnumerable<string> CommandLine.Core.Specification.EnumValues
get

Definition at line 68 of file Specification.cs.

68{ get; }

◆ HelpText

string CommandLine.Core.Specification.HelpText
get

Definition at line 64 of file Specification.cs.

64{ get; }

◆ Hidden

bool CommandLine.Core.Specification.Hidden
get

Definition at line 75 of file Specification.cs.

75{ get; }

◆ Max

Maybe<int> CommandLine.Core.Specification.Max
get

Definition at line 60 of file Specification.cs.

60{ get; }

◆ MetaValue

string CommandLine.Core.Specification.MetaValue
get

Definition at line 66 of file Specification.cs.

66{ get; }

◆ Min

Maybe<int> CommandLine.Core.Specification.Min
get

Definition at line 58 of file Specification.cs.

58{ get; }

◆ Required

bool CommandLine.Core.Specification.Required
get

Definition at line 56 of file Specification.cs.

56{ get; }

◆ Tag

SpecificationType CommandLine.Core.Specification.Tag
get

Definition at line 54 of file Specification.cs.

54{ get; }

◆ TargetType

TargetType CommandLine.Core.Specification.TargetType
get

Definition at line 73 of file Specification.cs.

73{ get; }

The documentation for this class was generated from the following file: