Class GeneralExtensions
General extensions for common cases
Inheritance
Namespace: HarmonyLib
Assembly: 0Harmony.dll
Syntax
public static class GeneralExtensions
Methods
| Improve this Doc View SourceDescription(Type[])
Converts an array of types (for example methods arguments) into a human readable form
Declaration
public static string Description(this Type[] parameters)
Parameters
Type | Name | Description |
---|---|---|
System.Type[] | parameters | The array of types |
Returns
Type | Description |
---|---|
System.String | A human readable description including brackets |
FullDescription(MethodBase)
A a full description of a method or a constructor without assembly details but with generics
Declaration
public static string FullDescription(this MethodBase member)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.MethodBase | member | The method/constructor |
Returns
Type | Description |
---|---|
System.String | A human readable description |
FullDescription(Type)
A full description of a type
Declaration
public static string FullDescription(this Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The type |
Returns
Type | Description |
---|---|
System.String | A human readable description |
GetTypedValue<T>(Dictionary<String, Object>, String)
A helper to access a value via key from a dictionary with extra casting
Declaration
public static T GetTypedValue<T>(this Dictionary<string, object> dictionary, string key)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.Dictionary<System.String, System.Object> | dictionary | The dictionary |
System.String | key | The key |
Returns
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 |
Type Parameters
Name | Description |
---|---|
T | The value type |
GetValueSafe<S, T>(Dictionary<S, T>, S)
A helper to access a value via key from a dictionary
Declaration
public static T GetValueSafe<S, T>(this Dictionary<S, T> dictionary, S key)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.Dictionary<S, T> | dictionary | The dictionary |
S | key | The key |
Returns
Type | Description |
---|---|
T | The value for the key or the default value (of T) if that key does not exist |
Type Parameters
Name | Description |
---|---|
S | The key type |
T | The value type |
Join<T>(IEnumerable<T>, Func<T, String>, String)
Joins an enumeration with a value converter and a delimiter to a string
Declaration
public static string Join<T>(this IEnumerable<T> enumeration, Func<T, string> converter = null, string delimiter = ", ")
Parameters
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 |
Returns
Type | Description |
---|---|
System.String | The values joined into a string |
Type Parameters
Name | Description |
---|---|
T | The inner type of the enumeration |
ToLiteral(String, String)
Escapes Unicode and ASCII non printable characters
Declaration
public static string ToLiteral(this string input, string quoteChar = "\"")
Parameters
Type | Name | Description |
---|---|---|
System.String | input | The string to convert |
System.String | quoteChar | The string to convert |
Returns
Type | Description |
---|---|
System.String | A string literal surrounded by |
Types(ParameterInfo[])
A helper converting parameter infos to types
Declaration
public static Type[] Types(this ParameterInfo[] pinfo)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.ParameterInfo[] | pinfo | The array of parameter infos |
Returns
Type | Description |
---|---|
System.Type[] | An array of types |