BadScript 2
Loading...
Searching...
No Matches
CommandLine.Text.MultilineTextAttribute Class Referenceabstract

Provides base properties for creating an attribute, used to define multiple lines of text. More...

Inheritance diagram for CommandLine.Text.MultilineTextAttribute:
CommandLine.Text.AssemblyLicenseAttribute CommandLine.Text.AssemblyUsageAttribute

Protected Member Functions

 MultilineTextAttribute (string line1)
 Initializes a new instance of the MultilineTextAttribute class. Used in derived type using one line of text.
 
 MultilineTextAttribute (string line1, string line2)
 Initializes a new instance of the MultilineTextAttribute class. Used in type using two lines of text.
 
 MultilineTextAttribute (string line1, string line2, string line3)
 Initializes a new instance of the MultilineTextAttribute class. Used in type using three lines of text.
 
 MultilineTextAttribute (string line1, string line2, string line3, string line4)
 Initializes a new instance of the MultilineTextAttribute class. Used in type using four lines of text.
 
 MultilineTextAttribute (string line1, string line2, string line3, string line4, string line5)
 Initializes a new instance of the MultilineTextAttribute class. Used in type using five lines of text.
 
virtual int GetLastLineWithText (string[] value)
 Returns the last line with text. Preserves blank lines if user intended by skipping a line.
 

Package Functions

HelpText AddToHelpText (HelpText helpText, Func< string, HelpText > func)
 
HelpText AddToHelpText (HelpText helpText, bool before)
 

Properties

virtual string Value [get]
 Gets the all non-blank lines as string.
 
string Line1 [get]
 Gets the first line of text.
 
string Line2 [get]
 Gets the second line of text.
 
string Line3 [get]
 Gets third line of text.
 
string Line4 [get]
 Gets the fourth line of text.
 
string Line5 [get]
 Gets the fifth line of text.
 

Detailed Description

Provides base properties for creating an attribute, used to define multiple lines of text.

Definition at line 12 of file MultiLineTextAttribute.cs.

Constructor & Destructor Documentation

◆ MultilineTextAttribute() [1/5]

CommandLine.Text.MultilineTextAttribute.MultilineTextAttribute ( string  line1)
protected

Initializes a new instance of the MultilineTextAttribute class. Used in derived type using one line of text.

Parameters
line1The first line of text.

Definition at line 19 of file MultiLineTextAttribute.cs.

20 : this(line1, string.Empty, string.Empty, string.Empty, string.Empty) { }

◆ MultilineTextAttribute() [2/5]

CommandLine.Text.MultilineTextAttribute.MultilineTextAttribute ( string  line1,
string  line2 
)
protected

Initializes a new instance of the MultilineTextAttribute class. Used in type using two lines of text.

Parameters
line1The first line of text.
line2The second line of text.

Definition at line 28 of file MultiLineTextAttribute.cs.

29 : this(line1, line2, string.Empty, string.Empty, string.Empty) { }

◆ MultilineTextAttribute() [3/5]

CommandLine.Text.MultilineTextAttribute.MultilineTextAttribute ( string  line1,
string  line2,
string  line3 
)
protected

Initializes a new instance of the MultilineTextAttribute class. Used in type using three lines of text.

Parameters
line1The first line of text.
line2The second line of text.
line3The third line of text.

Definition at line 38 of file MultiLineTextAttribute.cs.

39 : this(line1, line2, line3, string.Empty, string.Empty) { }

◆ MultilineTextAttribute() [4/5]

CommandLine.Text.MultilineTextAttribute.MultilineTextAttribute ( string  line1,
string  line2,
string  line3,
string  line4 
)
protected

Initializes a new instance of the MultilineTextAttribute class. Used in type using four lines of text.

Parameters
line1The first line of text.
line2The second line of text.
line3The third line of text.
line4The fourth line of text.

Definition at line 49 of file MultiLineTextAttribute.cs.

50 : this(line1, line2, line3, line4, string.Empty) { }

◆ MultilineTextAttribute() [5/5]

CommandLine.Text.MultilineTextAttribute.MultilineTextAttribute ( string  line1,
string  line2,
string  line3,
string  line4,
string  line5 
)
protected

Initializes a new instance of the MultilineTextAttribute class. Used in type using five lines of text.

Parameters
line1The first line of text.
line2The second line of text.
line3The third line of text.
line4The fourth line of text.
line5The fifth line of text.

Definition at line 61 of file MultiLineTextAttribute.cs.

62 {
63 if (line1 == null)
64 {
65 throw new ArgumentException("line1");
66 }
67
68 if (line2 == null)
69 {
70 throw new ArgumentException("line2");
71 }
72
73 if (line3 == null)
74 {
75 throw new ArgumentException("line3");
76 }
77
78 if (line4 == null)
79 {
80 throw new ArgumentException("line4");
81 }
82
83 if (line5 == null)
84 {
85 throw new ArgumentException("line5");
86 }
87
88 Line1 = line1;
89 Line2 = line2;
90 Line3 = line3;
91 Line4 = line4;
92 Line5 = line5;
93 }
string Line4
Gets the fourth line of text.
string Line2
Gets the second line of text.
string Line1
Gets the first line of text.
string Line5
Gets the fifth line of text.

Member Function Documentation

◆ AddToHelpText() [1/2]

HelpText CommandLine.Text.MultilineTextAttribute.AddToHelpText ( HelpText  helpText,
bool  before 
)
package

Definition at line 148 of file MultiLineTextAttribute.cs.

149 {
150 // before flag only distinguishes which action is called,
151 // so refactor common code and call with appropriate func
152 return before
153 ? AddToHelpText(helpText, helpText.AddPreOptionsLine)
154 : AddToHelpText(helpText, helpText.AddPostOptionsLine);
155 }
HelpText AddToHelpText(HelpText helpText, Func< string, HelpText > func)

◆ AddToHelpText() [2/2]

HelpText CommandLine.Text.MultilineTextAttribute.AddToHelpText ( HelpText  helpText,
Func< string, HelpText func 
)
package

Definition at line 140 of file MultiLineTextAttribute.cs.

141 {
142 string[] strArray = { Line1, Line2, Line3, Line4, Line5 };
143
144 return strArray.Take(GetLastLineWithText(strArray))
145 .Aggregate(helpText, (current, line) => func(line));
146 }
virtual int GetLastLineWithText(string[] value)
Returns the last line with text. Preserves blank lines if user intended by skipping a line.

◆ GetLastLineWithText()

virtual int CommandLine.Text.MultilineTextAttribute.GetLastLineWithText ( string[]  value)
protectedvirtual

Returns the last line with text. Preserves blank lines if user intended by skipping a line.

Returns
The last index of line of the non-blank line.
Parameters
valueThe string array to process.

Definition at line 164 of file MultiLineTextAttribute.cs.

165 {
166 int index = Array.FindLastIndex(value, str => !string.IsNullOrEmpty(str));
167
168 // remember FindLastIndex returns zero-based index
169 return index + 1;
170 }

Property Documentation

◆ Line1

string CommandLine.Text.MultilineTextAttribute.Line1
get

Gets the first line of text.

Definition at line 118 of file MultiLineTextAttribute.cs.

118{ get; }

◆ Line2

string CommandLine.Text.MultilineTextAttribute.Line2
get

Gets the second line of text.

Definition at line 123 of file MultiLineTextAttribute.cs.

123{ get; }

◆ Line3

string CommandLine.Text.MultilineTextAttribute.Line3
get

Gets third line of text.

Definition at line 128 of file MultiLineTextAttribute.cs.

128{ get; }

◆ Line4

string CommandLine.Text.MultilineTextAttribute.Line4
get

Gets the fourth line of text.

Definition at line 133 of file MultiLineTextAttribute.cs.

133{ get; }

◆ Line5

string CommandLine.Text.MultilineTextAttribute.Line5
get

Gets the fifth line of text.

Definition at line 138 of file MultiLineTextAttribute.cs.

138{ get; }

◆ Value

virtual string CommandLine.Text.MultilineTextAttribute.Value
get

Gets the all non-blank lines as string.

A string of all non-blank lines.

Definition at line 99 of file MultiLineTextAttribute.cs.

100 {
101 get
102 {
103 StringBuilder value = new StringBuilder(string.Empty);
104 string[] strArray = { Line1, Line2, Line3, Line4, Line5 };
105
106 for (int i = 0; i < GetLastLineWithText(strArray); i++)
107 {
108 value.AppendLine(strArray[i]);
109 }
110
111 return value.ToString();
112 }
113 }

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