C# Класс Aspectacular.Aspect

Base class for all method interceptors
Наследование: IAspect
Показать файл Открыть проект Примеры использования класса

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

Метод Описание
GetLogText ( Func entrySelector = null ) : string

Generates log text from a collection of log entries specified by entrySelector delegate. If entrySelector is null, all entries are used generate log text. Environment.NewLine as line separator.

GetLogText ( string lineSeparator, Func entrySelector = null ) : string

Generates log text from a collection of log entries specified by entrySelector delegate. If entrySelector is null, all entries are used generate log text. Environment.NewLine as line separator.

Step_1_BeforeResolvingInstance ( ) : void

Called for non-static methods only. Please note that method metadata is not available at this point.

Step_2_BeforeTryingMethodExec ( ) : void

Called right before intercepted method execution.

Step_3_BeforeMassagingReturnedResult ( ) : void

Called after intercepted method returned result and before interceptor augmented it, usually by LINQ modifiers like List(). May be called multiple times if retries are enabled.

LINQ's List(), Single(), etc. methods may be used to execute query returned by the intercepted method. This interceptor is called after query was returned and before it was executed. During this period, Context.ReturnedValue has exact value returned by the intercepted method. After this interceptor is called, Context.ReturnedValue may be changed, primarily by LINQ modifiers, like List().

Step_4_Optional_AfterCatchingMethodExecException ( ) : void

Called after method execution failed (thrown an exception).

Step_4_Optional_AfterSuccessfulCallCompletion ( ) : void

Called after method itself and optional result massager were called successfully. May be called multiple times when retries are enabled.

Since this method may be called multiple times on retries, put all finalization/cleanup logic into steps 5-7.

Step_5_FinallyAfterMethodExecution ( bool interceptedCallSucceeded ) : void

Called after method execution success or failure.

Step_6_Optional_AfterInstanceCleanup ( ) : void

Called only for instance method that have instance cleanup

Step_7_AfterEverythingSaidAndDone ( ) : void

The very final cutpoint in the life cycle of the call.

Защищенные методы

Метод Описание
CancelInterceptedMethodCallAndSetReturnValue ( object newReturnValue ) : void

This method can be used by caching aspects to supply return value without calling method itself.

Log ( EntryType entryType, string optionalKey, string format ) : void

Adds entry to the log held by the proxy.

LogError ( string format ) : void

Shortcut for logging error entries.

LogErrorWithKey ( string optionalKey, string format ) : void

Shortcut for logging error entries.

LogInformation ( string format ) : void

Shortcut for logging information entries.

LogInformationData ( string optionalKey, object data ) : void

Shortcut for logging information entries.

LogInformationWithKey ( string optionalKey, string format ) : void

Shortcut for logging information entries.

LogWarning ( string format ) : void

Shortcut for logging warning entries.

LogWarningWithKey ( string optionalKey, string format ) : void

Shortcut for logging warning entries.

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

Метод Описание
Aspect ( ) : System

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

CancelInterceptedMethodCallAndSetReturnValue() защищенный Метод

This method can be used by caching aspects to supply return value without calling method itself.
protected CancelInterceptedMethodCallAndSetReturnValue ( object newReturnValue ) : void
newReturnValue object
Результат void

GetLogText() публичный Метод

Generates log text from a collection of log entries specified by entrySelector delegate. If entrySelector is null, all entries are used generate log text. Environment.NewLine as line separator.
public GetLogText ( Func entrySelector = null ) : string
entrySelector Func /// Optional entry log filter delegate that may use entry.ToString() or its own logic to /// generate text for each selected log entry. ///
Результат string

GetLogText() публичный Метод

Generates log text from a collection of log entries specified by entrySelector delegate. If entrySelector is null, all entries are used generate log text. Environment.NewLine as line separator.
public GetLogText ( string lineSeparator, Func entrySelector = null ) : string
lineSeparator string
entrySelector Func /// Optional entry log filter delegate that may use entry.ToString() or its own logic to /// generate text for each selected log entry. ///
Результат string

Log() защищенный Метод

Adds entry to the log held by the proxy.
protected Log ( EntryType entryType, string optionalKey, string format ) : void
entryType EntryType
optionalKey string
format string
Результат void

LogError() защищенный Метод

Shortcut for logging error entries.
protected LogError ( string format ) : void
format string
Результат void

LogErrorWithKey() защищенный Метод

Shortcut for logging error entries.
protected LogErrorWithKey ( string optionalKey, string format ) : void
optionalKey string
format string
Результат void

LogInformation() защищенный Метод

Shortcut for logging information entries.
protected LogInformation ( string format ) : void
format string
Результат void

LogInformationData() защищенный Метод

Shortcut for logging information entries.
protected LogInformationData ( string optionalKey, object data ) : void
optionalKey string
data object
Результат void

LogInformationWithKey() защищенный Метод

Shortcut for logging information entries.
protected LogInformationWithKey ( string optionalKey, string format ) : void
optionalKey string
format string
Результат void

LogWarning() защищенный Метод

Shortcut for logging warning entries.
protected LogWarning ( string format ) : void
format string
Результат void

LogWarningWithKey() защищенный Метод

Shortcut for logging warning entries.
protected LogWarningWithKey ( string optionalKey, string format ) : void
optionalKey string
format string
Результат void

Step_1_BeforeResolvingInstance() публичный Метод

Called for non-static methods only. Please note that method metadata is not available at this point.
public Step_1_BeforeResolvingInstance ( ) : void
Результат void

Step_2_BeforeTryingMethodExec() публичный Метод

Called right before intercepted method execution.
public Step_2_BeforeTryingMethodExec ( ) : void
Результат void

Step_3_BeforeMassagingReturnedResult() публичный Метод

Called after intercepted method returned result and before interceptor augmented it, usually by LINQ modifiers like List(). May be called multiple times if retries are enabled.
LINQ's List(), Single(), etc. methods may be used to execute query returned by the intercepted method. This interceptor is called after query was returned and before it was executed. During this period, Context.ReturnedValue has exact value returned by the intercepted method. After this interceptor is called, Context.ReturnedValue may be changed, primarily by LINQ modifiers, like List().
public Step_3_BeforeMassagingReturnedResult ( ) : void
Результат void

Step_4_Optional_AfterCatchingMethodExecException() публичный Метод

Called after method execution failed (thrown an exception).
public Step_4_Optional_AfterCatchingMethodExecException ( ) : void
Результат void

Step_4_Optional_AfterSuccessfulCallCompletion() публичный Метод

Called after method itself and optional result massager were called successfully. May be called multiple times when retries are enabled.
Since this method may be called multiple times on retries, put all finalization/cleanup logic into steps 5-7.
public Step_4_Optional_AfterSuccessfulCallCompletion ( ) : void
Результат void

Step_5_FinallyAfterMethodExecution() публичный Метод

Called after method execution success or failure.
public Step_5_FinallyAfterMethodExecution ( bool interceptedCallSucceeded ) : void
interceptedCallSucceeded bool
Результат void

Step_6_Optional_AfterInstanceCleanup() публичный Метод

Called only for instance method that have instance cleanup
public Step_6_Optional_AfterInstanceCleanup ( ) : void
Результат void

Step_7_AfterEverythingSaidAndDone() публичный Метод

The very final cutpoint in the life cycle of the call.
public Step_7_AfterEverythingSaidAndDone ( ) : void
Результат void