Volume Control
Application-specific hotkeys for Windows
VolumeControl.Core.Helpers.StringHelper Class Reference

Defines helper methods & extension methods for creating nicely-formatted strings. More...

Collaboration diagram for VolumeControl.Core.Helpers.StringHelper:

Public Types

enum class  MethodNamePart {
  None = 0 , FullTypeNames = 1 , FullDeclaringTypeName = 2 , GenericParameters = 4 ,
  ParameterTypes = 8 , ParameterNames = 16 , Parameters = ParameterTypes | ParameterNames , NonVoidReturnType = 32 ,
  VoidReturnType = 64 , ReturnType = NonVoidReturnType | VoidReturnType
}
 Defines the components of a method name. More...
 

Static Public Member Functions

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...
 

Detailed Description

Defines helper methods & extension methods for creating nicely-formatted strings.

Member Enumeration Documentation

◆ 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.

Member Function Documentation

◆ 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.
includedNameComponentsThe 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
maxLengthThe length of the space to fill.
usedLengthThe number of characters out of the specified maxLength that have already been used.
fillCharThe character to use.
allowZeroLengthWhen 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
maxLengthThe length of the space to fill.
usedLengthThe number of characters out of the specified maxLength that have already been used.
fillCharThe pattern fill character.
dotCharThe pattern dot character.
allowZeroLengthWhen true, the returned string can be empty; otherwise when false, it always has at least one character.
alignRightWhen 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().

Here is the call graph for this function:

◆ 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
lengthThe length of the returned string.
fillCharThe pattern fill character.
dotCharThe pattern dot character.
alignRightWhen 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
ArgumentOutOfRangeExceptionlength was negative.

Referenced by VolumeControl.Core.Helpers.StringHelper.IndentWithPattern().

Here is the caller graph for this function:

◆ 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: