Defines helper methods & extension methods for creating nicely-formatted strings.
More...
|
static string | MakeAlternatingPattern (int length, char fillChar=' ', char dotChar='.', bool alignRight=true) |
| Returns a new string containing an alternating pattern of the specified characters with the specified length . More...
|
|
static string | IndentWithPattern (int maxLength, int usedLength=0, char fillChar=' ', char dotChar='.', bool allowZeroLength=false, bool alignRight=true) |
| Returns an alternating pattern long enough to fill the specified maxLength after subtracting the usedLength . More...
|
|
static string | Indent (int maxLength, int usedLength, char fillChar=' ', bool allowZeroLength=false) |
| Returns a string long enough to fill the specified maxLength after subtracting the specified usedLength . More...
|
|
static string | Indent (int maxLength, int usedLength, bool allowZeroLength) |
|
static string | GetFullMethodName (this MethodInfo method, MethodNamePart includedNameComponents) |
| Gets the name of the method with the specified includedNameComponents . More...
|
|
static string | GetFullMethodName (this MethodInfo method) |
| Gets the name of the method. More...
|
|
static string | PartialFormat (string format, params(int, object)[] formatArgs) |
| Emulates string.Format(string, object?[]), but allows partial formatting for specific arguments rather than all of them at once. More...
|
|
Defines helper methods & extension methods for creating nicely-formatted strings.
◆ MethodNamePart
Defines the components of a method name.
Enumerator |
---|
None | Shows only the declaring type name and the method name, with empty brackets.
|
FullTypeNames | Shows namespace qualifiers for all types.
|
FullDeclaringTypeName | Shows namespace qualifiers for the declaring type.
|
GenericParameters | Shows generic type parameters.
|
ParameterTypes | Shows parameter types.
|
ParameterNames | Shows parameter names.
|
Parameters | Shows parameter types and names.
|
NonVoidReturnType | Shows the return type, but only if it isn't void.
|
VoidReturnType | Shows the return type, even if it is void.
|
ReturnType | Shows the return type.
|
◆ GetFullMethodName() [1/2]
static string VolumeControl.Core.Helpers.StringHelper.GetFullMethodName |
( |
this MethodInfo |
method | ) |
|
|
static |
Gets the name of the method.
- Parameters
-
method | (implicit) The MethodInfo object of the method to get the name of. |
- Returns
- The full name of the method , including the full declaring typename, generic parameters, parameters, and return type (if not void).
◆ GetFullMethodName() [2/2]
static string VolumeControl.Core.Helpers.StringHelper.GetFullMethodName |
( |
this MethodInfo |
method, |
|
|
MethodNamePart |
includedNameComponents |
|
) |
| |
|
static |
Gets the name of the method with the specified includedNameComponents .
- Parameters
-
method | (implicit) The MethodInfo object of the method to get the name of. |
includedNameComponents | The parts of the method name to include. |
- Returns
- The name of the method with the includedNameComponents shown.
◆ Indent()
static string VolumeControl.Core.Helpers.StringHelper.Indent |
( |
int |
maxLength, |
|
|
int |
usedLength, |
|
|
char |
fillChar = ' ' , |
|
|
bool |
allowZeroLength = false |
|
) |
| |
|
static |
Returns a string long enough to fill the specified maxLength after subtracting the specified usedLength .
- Parameters
-
maxLength | The length of the space to fill. |
usedLength | The number of characters out of the specified maxLength that have already been used. |
fillChar | The character to use. |
allowZeroLength | When true , the returned string can be empty; otherwise when false , it always has at least one character. |
- Returns
- An indentation string with the requested length.
◆ IndentWithPattern()
static string VolumeControl.Core.Helpers.StringHelper.IndentWithPattern |
( |
int |
maxLength, |
|
|
int |
usedLength = 0 , |
|
|
char |
fillChar = ' ' , |
|
|
char |
dotChar = '.' , |
|
|
bool |
allowZeroLength = false , |
|
|
bool |
alignRight = true |
|
) |
| |
|
static |
Returns an alternating pattern long enough to fill the specified maxLength after subtracting the usedLength .
If the usedLength is greater than the maxLength , the returned string contains exactly 1 fillChar instead of throwing an exception.
- Parameters
-
maxLength | The length of the space to fill. |
usedLength | The number of characters out of the specified maxLength that have already been used. |
fillChar | The pattern fill character. |
dotChar | The pattern dot character. |
allowZeroLength | When true , the returned string can be empty; otherwise when false , it always has at least one character. |
alignRight | When true , the pattern is aligned to the right; otherwise when false it is aligned to the left. |
- Returns
- An indentation string made up of alternating characters with the requested length.
References VolumeControl.Core.Helpers.StringHelper.MakeAlternatingPattern().
◆ MakeAlternatingPattern()
static string VolumeControl.Core.Helpers.StringHelper.MakeAlternatingPattern |
( |
int |
length, |
|
|
char |
fillChar = ' ' , |
|
|
char |
dotChar = '.' , |
|
|
bool |
alignRight = true |
|
) |
| |
|
static |
Returns a new string containing an alternating pattern of the specified characters with the specified length .
This method is used to create spacer strings for text-based displays rendered with monospace fonts. The specified dotChar will never be the first or last character, so if the specified length is 2 or less, the returned string will only contain fillChar s.
To automatically calculate the needed length, see the IndentWithPattern method.
- Parameters
-
length | The length of the returned string. |
fillChar | The pattern fill character. |
dotChar | The pattern dot character. |
alignRight | When true , the pattern is aligned to the right; otherwise when false it is aligned to the left. |
- Returns
- An alternating pattern of the specified fillChar & dotChar with the specified length .
- Exceptions
-
ArgumentOutOfRangeException | length was negative. |
Referenced by VolumeControl.Core.Helpers.StringHelper.IndentWithPattern().
◆ PartialFormat()
static string VolumeControl.Core.Helpers.StringHelper.PartialFormat |
( |
string |
format, |
|
|
params(int, object)[] |
formatArgs |
|
) |
| |
|
static |
Emulates string.Format(string, object?[]), but allows partial formatting for specific arguments rather than all of them at once.
The documentation for this class was generated from the following file:
- /home/runner/work/volume-control/volume-control/VolumeControl.Core/Helpers/StringHelper.cs