C# Класс Microsoft.Scripting.Runtime.LightExceptions

Provides support for light exceptions. These exceptions are propagated by returning an instance of a private wrapper class containing the exception. Code which is aware of light exceptions will branch to apporiate exception handling blocks when in a try and otherwise return the value up the stack. This avoids using the underlying CLR exception mechanism with overhead such as creating stack traces. When a light exception reaches the boundary of code which is not light exception aware the caller must check to see if a light exception is being thrown and if so raise a .NET exception. This class provides methods for re-writing expression trees to support light exceptions, methods to create light throw objects, check if an object is a light throw object, and turn such an object back into a .NET Exception which can be thrown. Light exceptions also don't build up stack traces or interoperate with filter blocks via 2-pass exception handling.
Показать файл Открыть проект

Открытые методы

Метод Описание
CheckAndThrow ( Expression expr ) : Expression

Wraps the expression in a check and rethrow.

CheckAndThrow ( object value ) : object

Throws the exception if the value represents a light exception

GetLightException ( object exceptionValue ) : Exception

Gets the light exception from an object which may contain a light exception. Returns null if the object is not a light exception. Used for throwing the exception at non-light exception boundaries.

IsLightException ( object value ) : bool

Checks to see if the provided value is a light exception.

Rewrite ( Expression expression ) : Expression

Rewrites the provided expression to support light exceptions. Calls to the returned expression, if not from other light-weight aware calls, need to call GetLightException on return to see if an exception was thrown and if so throw it.

RewriteExternal ( Expression expression ) : Expression

Returns a new expression which is re-written for light exceptions but will throw an exception if it escapes the expression. If this expression is part of a larger experssion which is later re-written for light exceptions then it will propagate the light exception up.

RewriteLazy ( Expression expression ) : Expression

Returns a new expression which will lazily reduce to a light expression re-written version of the same expression.

SupportsLightThrow ( this binder ) : bool

Returns true if the call site binder is a light exception binder and supports light throws. Returns false otherwise.

Throw ( Expression exceptionValue ) : Expression

Returns an object which represents a light exception.

Throw ( Expression exceptionValue, Type retType ) : Expression

Returns an object which represents a light exception.

Throw ( this binder, Expression exceptionValue ) : Expression

If the binder supports light exceptions then a light exception throwing expression is returned. Otherwise a normal throwing expression is returned.

Throw ( this binder, Expression exceptionValue, Type retType ) : Expression

If the binder supports light exceptions then a light exception throwing expression is returned. Otherwise a normal throwing expression is returned.

Throw ( Exception exceptionValue ) : object

Returns an object which represents a light exception.

Приватные методы

Метод Описание
ThrowException ( LightException lightEx ) : void
ToReadOnly ( Expression args ) : ReadOnlyCollection

Описание методов

CheckAndThrow() публичный статический Метод

Wraps the expression in a check and rethrow.
public static CheckAndThrow ( Expression expr ) : Expression
expr Expression
Результат Expression

CheckAndThrow() публичный статический Метод

Throws the exception if the value represents a light exception
public static CheckAndThrow ( object value ) : object
value object
Результат object

GetLightException() публичный статический Метод

Gets the light exception from an object which may contain a light exception. Returns null if the object is not a light exception. Used for throwing the exception at non-light exception boundaries.
public static GetLightException ( object exceptionValue ) : Exception
exceptionValue object
Результат System.Exception

IsLightException() публичный статический Метод

Checks to see if the provided value is a light exception.
public static IsLightException ( object value ) : bool
value object
Результат bool

Rewrite() публичный статический Метод

Rewrites the provided expression to support light exceptions. Calls to the returned expression, if not from other light-weight aware calls, need to call GetLightException on return to see if an exception was thrown and if so throw it.
public static Rewrite ( Expression expression ) : Expression
expression Expression
Результат Expression

RewriteExternal() публичный статический Метод

Returns a new expression which is re-written for light exceptions but will throw an exception if it escapes the expression. If this expression is part of a larger experssion which is later re-written for light exceptions then it will propagate the light exception up.
public static RewriteExternal ( Expression expression ) : Expression
expression Expression
Результат Expression

RewriteLazy() публичный статический Метод

Returns a new expression which will lazily reduce to a light expression re-written version of the same expression.
public static RewriteLazy ( Expression expression ) : Expression
expression Expression
Результат Expression

SupportsLightThrow() публичный статический Метод

Returns true if the call site binder is a light exception binder and supports light throws. Returns false otherwise.
public static SupportsLightThrow ( this binder ) : bool
binder this
Результат bool

Throw() публичный статический Метод

Returns an object which represents a light exception.
public static Throw ( Expression exceptionValue ) : Expression
exceptionValue Expression
Результат Expression

Throw() публичный статический Метод

Returns an object which represents a light exception.
public static Throw ( Expression exceptionValue, Type retType ) : Expression
exceptionValue Expression
retType System.Type
Результат Expression

Throw() публичный статический Метод

If the binder supports light exceptions then a light exception throwing expression is returned. Otherwise a normal throwing expression is returned.
public static Throw ( this binder, Expression exceptionValue ) : Expression
binder this
exceptionValue Expression
Результат Expression

Throw() публичный статический Метод

If the binder supports light exceptions then a light exception throwing expression is returned. Otherwise a normal throwing expression is returned.
public static Throw ( this binder, Expression exceptionValue, Type retType ) : Expression
binder this
exceptionValue Expression
retType System.Type
Результат Expression

Throw() публичный статический Метод

Returns an object which represents a light exception.
public static Throw ( Exception exceptionValue ) : object
exceptionValue System.Exception
Результат object