docs/api/HarmonyLib.GeneralExtensions.html
General extensions for common cases
System.Object
GeneralExtensions
public static class GeneralExtensions
Converts an array of types (for example methods arguments) into a human readable form
public static string Description(this Type[] parameters)
| Type | Name | Description |
|---|---|---|
| System.Type[] | parameters |
The array of types
|
| Type | Description |
|---|---|
| System.String |
A human readable description including brackets
|
A a full description of a method or a constructor without assembly details but with generics
public static string FullDescription(this MethodBase member)
| Type | Name | Description |
|---|---|---|
| System.Reflection.MethodBase | member |
The method/constructor
|
| Type | Description |
|---|---|
| System.String |
A human readable description
|
A full description of a type
public static string FullDescription(this Type type)
| Type | Name | Description |
|---|---|---|
| System.Type | type |
The type
|
| Type | Description |
|---|---|
| System.String |
A human readable description
|
A helper to access a value via key from a dictionary with extra casting
public static T GetTypedValue<T>(this Dictionary<string, object> dictionary, string key)
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.Dictionary\ | dictionary |
The dictionary
| | System.String | key |
The key
|
| Type | Description |
|---|---|
| T |
The value for the key or the default value (of T) if that key does not exist or cannot be cast to T
|
| Name | Description |
|---|---|
| T |
The value type
|
A helper to access a value via key from a dictionary
public static T GetValueSafe<S, T>(this Dictionary<S, T> dictionary, S key)
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.Dictionary<S, T> | dictionary |
The dictionary
| | S | key |
The key
|
| Type | Description |
|---|---|
| T |
The value for the key or the default value (of T) if that key does not exist
|
| Name | Description |
|---|---|
| S |
The key type
| | T |
The value type
|
Tests if a type has the HarmonyAttribute
public static bool HasHarmonyAttribute(this Type type)
| Type | Name | Description |
|---|---|---|
| System.Type | type |
The class/type to test
|
| Type | Description |
|---|---|
| System.Boolean |
True if the type has the HarmonyAttribute
|
Joins an enumeration with a value converter and a delimiter to a string
public static string Join<T>(this IEnumerable<T> enumeration, Func<T, string> converter = null, string delimiter = ", ")
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T> | enumeration |
The enumeration
| | System.Func<T, System.String> | converter |
An optional value converter (from T to string)
| | System.String | delimiter |
An optional delimiter
|
| Type | Description |
|---|---|
| System.String |
The values joined into a string
|
| Name | Description |
|---|---|
| T |
The inner type of the enumeration
|
Escapes Unicode and ASCII non printable characters
public static string ToLiteral(this string input, string quoteChar = "\"")
| Type | Name | Description |
|---|---|---|
| System.String | input |
The string to convert
| | System.String | quoteChar |
The string to convert
|
| Type | Description |
|---|---|
| System.String |
A string literal surrounded by quoteChar
|
A helper converting parameter infos to types
public static Type[] Types(this ParameterInfo[] pinfo)
| Type | Name | Description |
|---|---|---|
| System.Reflection.ParameterInfo[] | pinfo |
The array of parameter infos
|
| Type | Description |
|---|---|
| System.Type[] |
An array of types
|