Class Utils
A class providing static utility functions that in any other language would just exist.
Namespace: IPA.Utilities
Assembly: IPA.Loader.dll
Syntax
public static class Utils : object
Properties
| Improve this Doc View SourceCanUseDateTimeNowSafely
Whether you can safely use
Declaration
public static bool CanUseDateTimeNowSafely { get; }
Property Value
Type | Description |
---|---|
Boolean | true if you can use |
Methods
| Improve this Doc View SourceByteArrayToString(Byte[])
Converts a byte array to a hex string.
Declaration
public static string ByteArrayToString(byte[] ba)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | ba | the byte array |
Returns
Type | Description |
---|---|
String | the hex form of the array |
CopyAll(DirectoryInfo, DirectoryInfo, String, Nullable<Func<Exception, FileInfo, Boolean>>)
Copies all files from source
to target
.
Declaration
public static void CopyAll(DirectoryInfo source, DirectoryInfo target, string appendFileName = "", Func<Exception, FileInfo, bool>? onCopyException = null)
Parameters
Type | Name | Description |
---|---|---|
DirectoryInfo | source | the source directory |
DirectoryInfo | target | the destination directory |
String | appendFileName | the filename of the file to append together |
Nullable<Func<Exception, FileInfo, Boolean>> | onCopyException | a delegate called when there is an error copying. Return true to keep going. |
CurrentTime()
Returns
Declaration
public static DateTime CurrentTime()
Returns
Type | Description |
---|---|
DateTime | the current |
Deconstruct<TKey, TValue>(KeyValuePair<TKey, TValue>, out TKey, out TValue)
Deconstructs a
Declaration
public static void Deconstruct<TKey, TValue>(this KeyValuePair<TKey, TValue> kvp, out TKey key, out TValue value)
Parameters
Type | Name | Description |
---|---|---|
KeyValuePair<TKey, TValue> | kvp | The |
TKey | key | The key in |
TValue | value | The value in |
Type Parameters
Name | Description |
---|---|
TKey | The type of the key. |
TValue | The type of the value. |
GetRelativePath(String, String)
Gets a path relative to the provided folder.
Declaration
public static string GetRelativePath(string file, string folder)
Parameters
Type | Name | Description |
---|---|---|
String | file | the file to relativize |
String | folder | the source folder |
Returns
Type | Description |
---|---|
String | a path to get from |
ScopeGuard(Action)
Creates a scope guard for a given
Declaration
public static Utils.ScopeGuardObject ScopeGuard(Action action)
Parameters
Type | Name | Description |
---|---|---|
Action | action | the |
Returns
Type | Description |
---|---|
Utils.ScopeGuardObject | a Utils.ScopeGuardObject that will run |
Examples
using var _ = Utils.ScopeGuard(() => RunOnScopeExit(value));
|
Improve this Doc
View Source
StringToByteArray(String)
Converts a hex string to a byte array.
Declaration
public static byte[] StringToByteArray(string hex)
Parameters
Type | Name | Description |
---|---|---|
String | hex | the hex stream |
Returns
Type | Description |
---|---|
Byte[] | the corresponding byte array |
UnsafeCompare(Byte[], Byte[])
Uses unsafe code to compare 2 byte arrays quickly.
Declaration
public static bool UnsafeCompare(byte[] a1, byte[] a2)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | a1 | array 1 |
Byte[] | a2 | array 2 |
Returns
Type | Description |
---|---|
Boolean | whether or not they are byte-for-byte equal |
VersionCompareNoPrerelease(Hive.Versioning.Version, Hive.Versioning.Version)
Compares a pair of
Declaration
public static int VersionCompareNoPrerelease(Hive.Versioning.Version l, Hive.Versioning.Version r)
Parameters
Type | Name | Description |
---|---|---|
Hive.Versioning.Version | l | the left value |
Hive.Versioning.Version | r | the right value |
Returns
Type | Description |
---|---|
Int32 | < 0 if l is less than r, 0 if they are equal in the numeric portion, or > 0 if l is greater than r |
VersionCompareNoPrerelease(Version, Version)
Compares a pair of Versions ignoring both the prerelease and build fields.
Declaration
public static int VersionCompareNoPrerelease(Version l, Version r)
Parameters
Type | Name | Description |
---|---|---|
Version | l | the left value |
Version | r | the right value |
Returns
Type | Description |
---|---|
Int32 | < 0 if l is less than r, 0 if they are equal in the numeric portion, or > 0 if l is greater than r |