Show / Hide Table of Contents

    Class ByteConverter

    This utility class is designed to make System.Byte related conversions easier to work with.

    Inheritance
    System.Object
    ByteConverter
    Namespace: Cuemon
    Assembly: Cuemon.Core.dll
    Syntax
    public static class ByteConverter

    Methods

    | Improve this Doc

    FromConvertibles<T>(T)

    Converts the specified value to an array of bytes.

    Declaration
    public static byte[] FromConvertibles<T>(T value)
        where T : struct, IConvertible
    Parameters
    Type Name Description
    T value

    The System.IConvertible value to convert.

    Returns
    Type Description
    System.Byte[]

    An array of bytes equivalent to the data of the value.

    Type Parameters
    Name Description
    T
    Exceptions
    Type Condition
    System.ArgumentOutOfRangeException

    value is outside the range of allowed types.
    Allowed types are: System.Boolean, System.Char, System.Double, System.Int16, System.Int32, System.UInt16, System.UInt32 and System.UInt64.

    | Improve this Doc

    FromConvertibles<T>(IEnumerable<T>)

    Converts the specified sequence of values to an array of bytes.

    Declaration
    public static byte[] FromConvertibles<T>(IEnumerable<T> values)
        where T : struct, IConvertible
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<T> values

    A sequence of System.IConvertible values to convert.

    Returns
    Type Description
    System.Byte[]

    An array of bytes equivalent to the sequence of the values.

    Type Parameters
    Name Description
    T
    Exceptions
    Type Condition
    System.ArgumentOutOfRangeException

    values is outside the range of allowed types.
    Allowed types are: System.Boolean, System.Char, System.Double, System.Int16, System.Int32, System.UInt16, System.UInt32 and System.UInt64.

    System.ArgumentNullException

    values is null.

    | Improve this Doc

    FromStream(Stream)

    Converts the specified value to a byte array always starting from position 0 (when supported).

    Declaration
    public static byte[] FromStream(Stream value)
    Parameters
    Type Name Description
    System.IO.Stream value

    The System.IO.Stream value to be converted.

    Returns
    Type Description
    System.Byte[]

    A byte array containing the data from the stream.

    | Improve this Doc

    FromStream(Stream, Boolean)

    Converts the specified value to a byte array.

    Declaration
    public static byte[] FromStream(Stream value, bool leaveStreamOpen)
    Parameters
    Type Name Description
    System.IO.Stream value

    The System.IO.Stream value to be converted.

    System.Boolean leaveStreamOpen

    if true, the System.IO.Stream object is being left open; otherwise it is being closed and disposed.

    Returns
    Type Description
    System.Byte[]

    A byte array containing the data from the stream.

    | Improve this Doc

    FromString(String, Action<EncodingOptions>)

    Converts the specified value to a byte array using the provided preferred encoding.

    Declaration
    public static byte[] FromString(string value, Action<EncodingOptions> setup = null)
    Parameters
    Type Name Description
    System.String value

    The string to be converted.

    System.Action<EncodingOptions> setup

    The EncodingOptions which need to be configured.

    Returns
    Type Description
    System.Byte[]

    A byte array which is the result of the specified delegate setup.

    Remarks

    EncodingOptions will be initialized with DefaultPreambleSequence and DefaultEncoding.

    | Improve this Doc

    FromUrlEncodedBase64(String)

    Decodes a URL string token to its equivalent byte array using base 64 digits.

    Declaration
    public static byte[] FromUrlEncodedBase64(string value)
    Parameters
    Type Name Description
    System.String value

    The URL string token to decode.

    Returns
    Type Description
    System.Byte[]

    The byte array containing the decoded URL string token.

    Remarks

    Source: http://tools.ietf.org/html/draft-ietf-jose-json-web-signature-08#appendix-C

    | Improve this Doc

    TryFromBase64String(String, out Byte[])

    Converts the string representation of a Base64 to its equivalent byte[] array.

    Declaration
    public static bool TryFromBase64String(string value, out byte[] result)
    Parameters
    Type Name Description
    System.String value

    The Base64 to convert.

    System.Byte[] result

    The array that will contain the parsed value.

    Returns
    Type Description
    System.Boolean

    true if the parse operation was successful; otherwise, false.

    Remarks

    This method returns false if value is null, empty or not in a recognized format, and does not throw an exception.
    result will have a default value of null.

    | Improve this Doc

    TryFromBase64String(String, Func<String, Boolean>, out Byte[])

    Converts the string representation of a Base64 to its equivalent byte[] array.

    Declaration
    public static bool TryFromBase64String(string value, Func<string, bool> predicate, out byte[] result)
    Parameters
    Type Name Description
    System.String value

    The Base64 to convert.

    System.Func<System.String, System.Boolean> predicate

    A function delegate that provides custom rules for bypassing the Base64 structure check.

    System.Byte[] result

    The array that will contain the parsed value.

    Returns
    Type Description
    System.Boolean

    true if the parse operation was successful; otherwise, false.

    Remarks

    This method returns false if value is null, empty or not in a recognized format, and does not throw an exception.
    result will have a default value of null.

    • Improve this Doc
    • View Source
    Back to top Copyright 2008-2018 Weubphoria. All rights reserved.
    Generated by DocFX