Пример #1
0
 /// <summary>
 /// Executes the callback in a volatile scope that is disposed after the execution.
 /// </summary>
 /// <param name="container">Container instance.</param>
 /// <param name="callback">Callback function to be executed in a volatile scope.</param>
 public static void ExecuteInVolatileScope(this IContainer container, Action <IVolatileContainer> callback)
 {
     using (var scope = new Implementation.ImplicitVolatileScope(container))
     {
         callback(scope.Container);
     }
 }
Пример #2
0
 /// <summary>
 /// Executes the async callback in a volatile scope that is disposed after the execution.
 /// </summary>
 /// <param name="container">Container instance.</param>
 /// <param name="callback">Async callback function to be executed in a volatile scope.</param>
 public static async Task ExecuteInVolatileScopeAsync(this IContainer container, Func <IVolatileContainer, Task> callback)
 {
     using (var scope = new Implementation.ImplicitVolatileScope(container))
     {
         await callback(scope.Container);
     }
 }
Пример #3
0
 /// <summary>
 /// Executes the callback in a volatile scope that is disposed after the execution.
 /// </summary>
 /// <returns>The value returned by callback.</returns>
 /// <param name="container">Container instance.</param>
 /// <param name="callback">Callback function to be executed in a volatile scope.</param>
 /// <typeparam name="T">The return value type of callback.</typeparam>
 public static T ExecuteInVolatileScope <T>(this IContainer container, Func <IVolatileContainer, T> callback)
 {
     using (var scope = new Implementation.ImplicitVolatileScope(container))
     {
         return(callback(scope.Container));
     }
 }