Models the heading part of an help text. You can assign it where you assign any System.String instance.
More...
|
| HeadingInfo (string programName, string version=null) |
| Initializes a new instance of the CommandLine.Text.HeadingInfo class specifying program name and version.
|
|
override string | ToString () |
| Returns the heading as a System.String.
|
|
void | WriteMessage (string message, TextWriter writer) |
| Writes out a string and a new line using the program name specified in the constructor and message parameter.
|
|
void | WriteMessage (string message) |
| Writes out a string and a new line using the program name specified in the constructor and message parameter to standard output stream.
|
|
void | WriteError (string message) |
| Writes out a string and a new line using the program name specified in the constructor and message parameter to standard error stream.
|
|
|
static HeadingInfo | Empty [get] |
| An empty object used for initialization.
|
|
static HeadingInfo | Default [get] |
| Gets the default heading instance. The title is retrieved from AssemblyTitleAttribute, or the assembly short name if its not defined. The version is retrieved from AssemblyInformationalVersionAttribute, or the assembly version if its not defined.
|
|
Models the heading part of an help text. You can assign it where you assign any System.String instance.
Definition at line 18 of file HeadingInfo.cs.
◆ HeadingInfo()
CommandLine.Text.HeadingInfo.HeadingInfo |
( |
string |
programName, |
|
|
string |
version = null |
|
) |
| |
Initializes a new instance of the CommandLine.Text.HeadingInfo class specifying program name and version.
- Parameters
-
programName | The name of the program. |
version | The version of the program. |
- Exceptions
-
System.ArgumentException | Thrown when parameter programName is null or empty string. |
Definition at line 33 of file HeadingInfo.cs.
34 {
35 if (string.IsNullOrWhiteSpace("programName"))
36 {
37 throw new ArgumentException("programName");
38 }
39
42 }
readonly string programName
◆ operator string()
static implicit CommandLine.Text.HeadingInfo.operator string |
( |
HeadingInfo |
info | ) |
|
|
static |
Converts the heading to a System.String.
- Parameters
-
- Returns
- The System.String that contains the heading.
Definition at line 80 of file HeadingInfo.cs.
81 {
82 return info.ToString();
83 }
◆ ToString()
override string CommandLine.Text.HeadingInfo.ToString |
( |
| ) |
|
Returns the heading as a System.String.
- Returns
- The System.String that contains the heading.
Definition at line 89 of file HeadingInfo.cs.
90 {
91 bool isVersionNull =
string.IsNullOrEmpty(
version);
92
94 (!isVersionNull ?
version.Length + 1 : 0)
95 )
97 .AppendWhen(!isVersionNull,
" ",
version)
99 }
override string ToString()
Returns the heading as a System.String.
◆ WriteError()
void CommandLine.Text.HeadingInfo.WriteError |
( |
string |
message | ) |
|
Writes out a string and a new line using the program name specified in the constructor and message parameter to standard error stream.
- Parameters
-
message | The System.String message to write. |
- Exceptions
-
System.ArgumentException | Thrown when parameter message is null or empty string. |
Definition at line 146 of file HeadingInfo.cs.
147 {
149 }
void WriteMessage(string message, TextWriter writer)
Writes out a string and a new line using the program name specified in the constructor and message p...
◆ WriteMessage() [1/2]
void CommandLine.Text.HeadingInfo.WriteMessage |
( |
string |
message | ) |
|
Writes out a string and a new line using the program name specified in the constructor and message parameter to standard output stream.
- Parameters
-
message | The System.String message to write. |
- Exceptions
-
System.ArgumentException | Thrown when parameter message is null or empty string. |
Definition at line 135 of file HeadingInfo.cs.
◆ WriteMessage() [2/2]
void CommandLine.Text.HeadingInfo.WriteMessage |
( |
string |
message, |
|
|
TextWriter |
writer |
|
) |
| |
Writes out a string and a new line using the program name specified in the constructor and message parameter.
- Parameters
-
message | The System.String message to write. |
writer | The target System.IO.TextWriter derived type. |
- Exceptions
-
System.ArgumentException | Thrown when parameter message is null or empty string. |
System.ArgumentNullException | Thrown when parameter writer is null. |
Definition at line 109 of file HeadingInfo.cs.
110 {
111 if (string.IsNullOrWhiteSpace("message"))
112 {
113 throw new ArgumentException("message");
114 }
115
116 if (writer == null)
117 {
118 throw new ArgumentNullException("writer");
119 }
120
121 writer.WriteLine(
new StringBuilder(
programName.Length + message.Length + 2)
123 .Append(": ")
124 .Append(message)
125 .ToString()
126 );
127 }
◆ programName
readonly string CommandLine.Text.HeadingInfo.programName |
|
private |
◆ version
readonly string CommandLine.Text.HeadingInfo.version |
|
private |
◆ Default
Gets the default heading instance. The title is retrieved from AssemblyTitleAttribute, or the assembly short name if its not defined. The version is retrieved from AssemblyInformationalVersionAttribute, or the assembly version if its not defined.
Definition at line 56 of file HeadingInfo.cs.
57 {
58 get
59 {
61 .MapValueOrDefault(titleAttribute => titleAttribute.Title,
63 );
64
66 .MapValueOrDefault(versionAttribute =>
67 versionAttribute.InformationalVersion,
69 );
70
72 }
73 }
static string GetAssemblyVersion()
static string GetAssemblyName()
HeadingInfo(string programName, string version=null)
Initializes a new instance of the CommandLine.Text.HeadingInfo class specifying program name and vers...
◆ Empty
An empty object used for initialization.
Definition at line 47 of file HeadingInfo.cs.
The documentation for this class was generated from the following file: