Search Results for

    Show / Hide Table of Contents

    Class Utils

    A class providing static utility functions that in any other language would just exist.

    Inheritance
    System.Object
    Utils
    Inherited Members
    System.Object.ToString()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: IPA.Utilities
    Assembly: IPA.Loader.dll
    Syntax
    public static class Utils

    Properties

    | Improve this Doc View Source

    CanUseDateTimeNowSafely

    Whether you can safely use System.DateTime.Now without Mono throwing a fit.

    Declaration
    public static bool CanUseDateTimeNowSafely { get; }
    Property Value
    Type Description
    System.Boolean

    true if you can use System.DateTime.Now safely, false otherwise

    Methods

    | Improve this Doc View Source

    ByteArrayToString(Byte[])

    Converts a byte array to a hex string.

    Declaration
    public static string ByteArrayToString(byte[] ba)
    Parameters
    Type Name Description
    System.Byte[] ba

    the byte array

    Returns
    Type Description
    System.String

    the hex form of the array

    | Improve this Doc View Source

    CopyAll(DirectoryInfo, DirectoryInfo, String, 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
    System.IO.DirectoryInfo source

    the source directory

    System.IO.DirectoryInfo target

    the destination directory

    System.String appendFileName

    the filename of the file to append together

    System.Func<System.Exception, System.IO.FileInfo, System.Boolean> onCopyException

    a delegate called when there is an error copying. Return true to keep going.

    | Improve this Doc View Source

    CurrentTime()

    Returns System.DateTime.Now if supported, otherwise System.DateTime.UtcNow.

    Declaration
    public static DateTime CurrentTime()
    Returns
    Type Description
    System.DateTime

    the current System.DateTime if supported, otherwise some indeterminant increasing value.

    | Improve this Doc View Source

    Deconstruct<TKey, TValue>(KeyValuePair<TKey, TValue>, out TKey, out TValue)

    Deconstructs a System.Collections.Generic.KeyValuePair<TKey, TValue> as its key and value.

    Declaration
    public static void Deconstruct<TKey, TValue>(this KeyValuePair<TKey, TValue> kvp, out TKey key, out TValue value)
    Parameters
    Type Name Description
    System.Collections.Generic.KeyValuePair<TKey, TValue> kvp

    The System.Collections.Generic.KeyValuePair<TKey, TValue> to deconstruct.

    TKey key

    The key in kvp.

    TValue value

    The value in kvp.

    Type Parameters
    Name Description
    TKey

    The type of the key.

    TValue

    The type of the value.

    | Improve this Doc View Source

    GetRelativePath(String, String)

    Gets a path relative to the provided folder.

    Declaration
    public static string GetRelativePath(string file, string folder)
    Parameters
    Type Name Description
    System.String file

    the file to relativize

    System.String folder

    the source folder

    Returns
    Type Description
    System.String

    a path to get from folder to file

    | Improve this Doc View Source

    ScopeGuard(Action)

    Creates a scope guard for a given System.Action.

    Declaration
    public static Utils.ScopeGuardObject ScopeGuard(Action action)
    Parameters
    Type Name Description
    System.Action action

    the System.Action to run on dispose

    Returns
    Type Description
    Utils.ScopeGuardObject

    a Utils.ScopeGuardObject that will run action on disposal

    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
    System.String hex

    the hex stream

    Returns
    Type Description
    System.Byte[]

    the corresponding byte array

    | Improve this Doc View Source

    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
    System.Byte[] a1

    array 1

    System.Byte[] a2

    array 2

    Returns
    Type Description
    System.Boolean

    whether or not they are byte-for-byte equal

    | Improve this Doc View Source

    VersionCompareNoPrerelease(Version, Version)

    Compares a pair of Hive.Versioning.Versions ignoring both the prerelease and build fields.

    Declaration
    public static int VersionCompareNoPrerelease(Version l, Version r)
    Parameters
    Type Name Description
    Hive.Versioning.Version l

    the left value

    Hive.Versioning.Version r

    the right value

    Returns
    Type Description
    System.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

    | Improve this Doc View Source

    VersionCompareNoPrerelease(Version, Version)

    Compares a pair of Versions ignoring both the prerelease and build fields.

    Declaration
    [Obsolete("Use Hive.Versioning.Version overload instead.")]
    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
    System.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

    • Improve this Doc
    • View Source
    In This Article
    Back to top Generated by DocFX