Table of Contents

Class OperatorRegistry

Namespace
Ecng.ComponentModel
Assembly
Ecng.ComponentModel.dll

Provides a registry for operators to perform mathematical and comparison operations.

public static class OperatorRegistry
Inheritance
OperatorRegistry
Inherited Members

Methods

AddOperator<T>(IOperator<T>)

Adds an operator for the specified type.

public static void AddOperator<T>(IOperator<T> @operator)

Parameters

operator IOperator<T>

The operator to add.

Type Parameters

T

The type that the operator will handle.

Exceptions

ArgumentNullException

Thrown when the operator is null.

GetOperator(Type)

Retrieves the operator associated with the specified type.

public static IOperator GetOperator(this Type type)

Parameters

type Type

The type for which to retrieve the operator.

Returns

IOperator

The operator associated with the given type.

Exceptions

InvalidOperationException

Thrown when no operator exists for the given type.

GetOperator<T>()

Retrieves the operator associated with the specified type parameter.

public static IOperator<T> GetOperator<T>()

Returns

IOperator<T>

The operator associated with the given type.

Type Parameters

T

The type for which to retrieve the operator.

IsRegistered(Type)

Checks if an operator is registered for the specified type.

public static bool IsRegistered(Type type)

Parameters

type Type

The type to check for operator registration.

Returns

bool

true if an operator is registered; otherwise, false.

IsRegistered<T>()

Checks if an operator is registered for the specified type parameter.

public static bool IsRegistered<T>()

Returns

bool

true if an operator is registered; otherwise, false.

Type Parameters

T

The type to check for operator registration.

RemoveOperator<T>(IOperator<T>)

Removes the operator for the specified type.

public static void RemoveOperator<T>(IOperator<T> @operator)

Parameters

operator IOperator<T>

The operator instance to remove.

Type Parameters

T

The type whose operator is to be removed.

Exceptions

ArgumentNullException

Thrown when the operator is null.

ThrowIfNegative(long, string)

Throws an exception if the specified long value is negative.

public static long ThrowIfNegative(this long value, string name)

Parameters

value long

The long value to check.

name string

The name of the variable to include in the exception.

Returns

long

The original value if it is not negative.

Exceptions

ArgumentOutOfRangeException

Thrown when the value is negative.

ThrowIfNegative(long?, string)

Throws an exception if the specified nullable long value is negative.

public static long? ThrowIfNegative(this long? value, string name)

Parameters

value long?

The nullable long value to check.

name string

The name of the variable to include in the exception.

Returns

long?

The original value if it is not negative; otherwise, null.