Show / Hide Table of Contents

    Class AssignmentUtility

    This utility class is designed to make arithmetic assignment operations for numeric operands easier to work with by using generics.

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

    Methods

    | Improve this Doc

    Add<T>(T, T)

    Performs a binary addition of the two specified values.

    Declaration
    public static T Add<T>(T x, T y)
        where T : struct, IConvertible
    Parameters
    Type Name Description
    T x

    The first value to add.

    T y

    The second value to add.

    Returns
    Type Description
    T

    The sum of x and y.

    Type Parameters
    Name Description
    T

    The type of the values for the operand operation.

    Exceptions
    Type Condition
    TypeArgumentException

    T is outside the range of allowed types.
    Allowed types are: System.Byte, System.Decimal, System.Double, System.Int16, System.Int32, System.Int64, System.SByte, System.Single, System.UInt16, System.UInt32 or System.UInt64.

    System.OverflowException

    The sum of x and y is less than or greater than the by T valid MinValue and MaxValue.

    | Improve this Doc

    And<T>(T, T)

    Performs a a bitwise logical conjunction (AND) operation of the two specified values.

    Declaration
    public static T And<T>(T x, T y)
        where T : struct, IConvertible
    Parameters
    Type Name Description
    T x

    The first value to AND.

    T y

    The second value to AND.

    Returns
    Type Description
    T

    The result of x AND y.

    Type Parameters
    Name Description
    T

    The type of the values for the operand operation.

    Exceptions
    Type Condition
    TypeArgumentException

    T is outside the range of allowed types.
    Allowed types are: System.Byte, System.Int16, System.Int32, System.Int64, System.SByte, System.UInt16, System.UInt32 or System.UInt64.

    | Improve this Doc

    Assign<T>(T, T)

    Performs an assignment of the right-hand operand to the left-hand operand.

    Declaration
    public static T Assign<T>(T x, T y)
        where T : struct, IConvertible
    Parameters
    Type Name Description
    T x

    The left-hand operand.

    T y

    The right-hand operand.

    Returns
    Type Description
    T

    The value of y.

    Type Parameters
    Name Description
    T

    The type of the values for the operand operation.

    Exceptions
    Type Condition
    TypeArgumentException

    T is outside the range of allowed types.
    Allowed types are: System.Byte, System.Decimal, System.Double, System.Int16, System.Int32, System.Int64, System.SByte, System.Single, System.UInt16, System.UInt32 or System.UInt64.

    | Improve this Doc

    Calculate<T>(T, AssignmentOperator, T)

    Performs a calculation following the assignment of the two specified values.

    Declaration
    public static T Calculate<T>(T x, AssignmentOperator assignment, T y)
        where T : struct, IConvertible
    Parameters
    Type Name Description
    T x

    The value to calculate with y.

    AssignmentOperator assignment

    One of the enumeration values that specifies the rules to apply for the assignment operator of x and y.

    T y

    The value to calculate with x.

    Returns
    Type Description
    T

    The result of the assignment for x and y.

    Type Parameters
    Name Description
    T

    The type of the values for the operand operation.

    Exceptions
    Type Condition
    TypeArgumentException

    T is outside the range of allowed types.
    Allowed types are: System.Byte, System.Decimal, System.Double, System.Int16, System.Int32, System.Int64, System.SByte, System.Single, System.UInt16, System.UInt32 or System.UInt64.

    | Improve this Doc

    Divide<T>(T, T)

    Performs a binary division of the two specified values.

    Declaration
    public static T Divide<T>(T x, T y)
        where T : struct, IConvertible
    Parameters
    Type Name Description
    T x

    The dividend.

    T y

    The divisor.

    Returns
    Type Description
    T

    The result of dividing x by y.

    Type Parameters
    Name Description
    T

    The type of the values for the operand operation.

    Exceptions
    Type Condition
    TypeArgumentException

    T is outside the range of allowed types.
    Allowed types are: System.Byte, System.Decimal, System.Double, System.Int16, System.Int32, System.Int64, System.SByte, System.Single, System.UInt16, System.UInt32 or System.UInt64.

    System.DivideByZeroException

    y is zero.

    System.OverflowException

    The sum of x and y is less than or greater than the by T valid MinValue and MaxValue.

    | Improve this Doc

    ExclusiveOr<T>(T, T)

    Performs a bitwise exclusive or (XOR) operation of the two specified values.

    Declaration
    public static T ExclusiveOr<T>(T x, T y)
        where T : struct, IConvertible
    Parameters
    Type Name Description
    T x

    The first value to XOR.

    T y

    The second value to XOR.

    Returns
    Type Description
    T

    The result of x XOR y.

    Type Parameters
    Name Description
    T

    The type of the values for the operand operation.

    Exceptions
    Type Condition
    TypeArgumentException

    T is outside the range of allowed types.
    Allowed types are: System.Byte, System.Int16, System.Int32, System.Int64, System.SByte, System.UInt16, System.UInt32 or System.UInt64.

    | Improve this Doc

    LeftShift<T>(T, T)

    Performs an arithmetic left shift (<<) operation.

    Declaration
    public static T LeftShift<T>(T x, T y)
        where T : struct, IConvertible
    Parameters
    Type Name Description
    T x

    The bit pattern to be shifted.

    T y

    The number of bits to shift the bit pattern.

    Returns
    Type Description
    T

    The result of shifting the bit pattern.

    Type Parameters
    Name Description
    T

    The type of the values for the operand operation.

    Exceptions
    Type Condition
    TypeArgumentException

    T is outside the range of allowed types.
    Allowed types are: System.Byte, System.Int16, System.Int32, System.SByte, System.UInt16.

    | Improve this Doc

    Multiply<T>(T, T)

    Performs a binary multiplication of the two specified values.

    Declaration
    public static T Multiply<T>(T x, T y)
        where T : struct, IConvertible
    Parameters
    Type Name Description
    T x

    The multiplicand.

    T y

    The multiplier.

    Returns
    Type Description
    T

    The result of multiplying x and y.

    Type Parameters
    Name Description
    T

    The type of the values for the operand operation.

    Exceptions
    Type Condition
    TypeArgumentException

    T is outside the range of allowed types.
    Allowed types are: System.Byte, System.Decimal, System.Double, System.Int16, System.Int32, System.Int64, System.SByte, System.Single, System.UInt16, System.UInt32 or System.UInt64.

    System.OverflowException

    The sum of x and y is less than or greater than the by T valid MinValue and MaxValue.

    | Improve this Doc

    Or<T>(T, T)

    Performs a bitwise logical disjunction (OR) operation of the two specified values.

    Declaration
    public static T Or<T>(T x, T y)
        where T : struct, IConvertible
    Parameters
    Type Name Description
    T x

    The first value to OR.

    T y

    The second value to OR.

    Returns
    Type Description
    T

    The result of x OR y.

    Type Parameters
    Name Description
    T

    The type of the values for the operand operation.

    Exceptions
    Type Condition
    TypeArgumentException

    T is outside the range of allowed types.
    Allowed types are: System.Byte, System.Int16, System.Int32, System.Int64, System.SByte, System.UInt16, System.UInt32 or System.UInt64.

    | Improve this Doc

    Remainder<T>(T, T)

    Performs a binary division of the two specified values and computes the remainder hereof.

    Declaration
    public static T Remainder<T>(T x, T y)
        where T : struct, IConvertible
    Parameters
    Type Name Description
    T x

    The dividend.

    T y

    The divisor.

    Returns
    Type Description
    T

    The remainder after dividing x by y.

    Type Parameters
    Name Description
    T

    The type of the values for the operand operation.

    Exceptions
    Type Condition
    TypeArgumentException

    T is outside the range of allowed types.
    Allowed types are: System.Byte, System.Decimal, System.Double, System.Int16, System.Int32, System.Int64, System.SByte, System.Single, System.UInt16, System.UInt32 or System.UInt64.

    System.DivideByZeroException

    y is zero.

    System.OverflowException

    The sum of x and y is less than or greater than the by T valid MinValue and MaxValue.

    | Improve this Doc

    RightShift<T>(T, T)

    Performs an arithmetic right shift (>>) operation.

    Declaration
    public static T RightShift<T>(T x, T y)
        where T : struct, IConvertible
    Parameters
    Type Name Description
    T x

    The bit pattern to be shifted.

    T y

    The number of bits to shift the bit pattern.

    Returns
    Type Description
    T

    The result of shifting the bit pattern.

    Type Parameters
    Name Description
    T

    The type of the values for the operand operation.

    Exceptions
    Type Condition
    TypeArgumentException

    T is outside the range of allowed types.
    Allowed types are: System.Byte, System.Int16, System.Int32, System.SByte, System.UInt16.

    | Improve this Doc

    Subtract<T>(T, T)

    Performs a binary subtraction of the two specified values.

    Declaration
    public static T Subtract<T>(T x, T y)
        where T : struct, IConvertible
    Parameters
    Type Name Description
    T x

    The minuend.

    T y

    The subtrahend.

    Returns
    Type Description
    T

    The result of subtracting y from x.

    Type Parameters
    Name Description
    T

    The type of the values for the operand operation.

    Exceptions
    Type Condition
    TypeArgumentException

    T is outside the range of allowed types.
    Allowed types are: System.Byte, System.Decimal, System.Double, System.Int16, System.Int32, System.Int64, System.SByte, System.Single, System.UInt16, System.UInt32 or System.UInt64.

    System.OverflowException

    The sum of x and y is less than or greater than the by T valid MinValue and MaxValue.

    | Improve this Doc

    ValidAsNumericOperand<T>()

    Validates if the specified T is within the allowed range of numeric operands.

    Declaration
    public static void ValidAsNumericOperand<T>()
        where T : struct, IComparable<T>, IEquatable<T>, IConvertible
    Type Parameters
    Name Description
    T

    The type of the value for an operand operation.

    Exceptions
    Type Condition
    System.ArgumentOutOfRangeException

    T is outside the range of allowed types.
    Allowed types are: System.Byte, System.Decimal, System.Double, System.Int16, System.Int32, System.Int64, System.SByte, System.Single, System.UInt16, System.UInt32 or System.UInt64.

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