Class GeneralExtensions
- Namespace
- HarmonyLib
- Assembly
- 0Harmony.dll
General extensions for common cases
public static class GeneralExtensions
- Inheritance
-
objectGeneralExtensions
Methods
Description(Type[])
Converts an array of types (for example methods arguments) into a human readable form
public static string Description(this Type[] parameters)
Parameters
parametersType[]The array of types
Returns
- 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
public static string FullDescription(this MethodBase member)
Parameters
memberMethodBaseThe method/constructor
Returns
- string
A human readable description
FullDescription(Type)
A full description of a type
public static string FullDescription(this Type type)
Parameters
typeTypeThe type
Returns
- 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
public static T GetTypedValue<T>(this Dictionary<string, object> dictionary, string key)
Parameters
dictionaryDictionary<string, object>The dictionary
keystringThe key
Returns
- 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
TThe value type
GetValueSafe<S, T>(Dictionary<S, T>, S)
A helper to access a value via key from a dictionary
public static T GetValueSafe<S, T>(this Dictionary<S, T> dictionary, S key)
Parameters
dictionaryDictionary<S, T>The dictionary
keySThe key
Returns
- T
The value for the key or the default value (of T) if that key does not exist
Type Parameters
SThe key type
TThe value type
HasHarmonyAttribute(Type)
Tests if a type has the HarmonyAttribute
public static bool HasHarmonyAttribute(this Type type)
Parameters
typeTypeThe class/type to test
Returns
- bool
True if the type has the HarmonyAttribute
Join<T>(IEnumerable<T>, Func<T, string>, string)
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 = ", ")
Parameters
enumerationIEnumerable<T>The enumeration
converterFunc<T, string>An optional value converter (from T to string)
delimiterstringAn optional delimiter
Returns
- string
The values joined into a string
Type Parameters
TThe inner type of the enumeration
ToLiteral(string, string)
Escapes Unicode and ASCII non printable characters
public static string ToLiteral(this string input, string quoteChar = "\"")
Parameters
inputstringThe string to convert
quoteCharstringThe string to convert
Returns
- string
A string literal surrounded by
quoteChar
Types(ParameterInfo[])
A helper converting parameter infos to types
public static Type[] Types(this ParameterInfo[] pinfo)
Parameters
pinfoParameterInfo[]The array of parameter infos
Returns
- Type[]
An array of types