/// <summary>
 /// Configures the Apworks framework by using Unity as the object container.
 /// </summary>
 /// <param name="configurator">The <see cref="IExceptionHandlerConfigurator"/> instance to be extended.</param>
 /// <param name="initFromConfigFile">The <see cref="System.Boolean"/> value which indicates whether the container configuration should be read from the config file.</param>
 /// <param name="sectionName">The name of the section in the config file. This value must be specified when the <paramref name="initFromConfigFile"/> parameter is set to true.</param>
 /// <returns>The <see cref="IObjectContainerConfigurator"/> instace.</returns>
 public static IObjectContainerConfigurator UsingUnityContainer(this IExceptionHandlerConfigurator configurator, bool initFromConfigFile = false, string sectionName = null)
 {
     return(configurator.UsingObjectContainer <UnityObjectContainer>(initFromConfigFile, sectionName));
 }
Пример #2
0
 /// <summary>
 /// Configures the Apworks framework by using the specified object container.
 /// </summary>
 /// <typeparam name="TObjectContainer">The type of the object container to be used by the framework.</typeparam>
 /// <param name="configurator">The <see cref="IExceptionHandlerConfigurator"/> instance to be extended.</param>
 /// <param name="initFromConfigFile">The <see cref="Boolean"/> value which indicates whether the container configuration should be read from the config file.</param>
 /// <param name="sectionName">The name of the section in the config file. This value must be specified when the <paramref name="initFromConfigFile"/> parameter is set to true.</param>
 /// <returns>The <see cref="IObjectContainerConfigurator"/> instance.</returns>
 public static IObjectContainerConfigurator UsingObjectContainer <TObjectContainer>(this IExceptionHandlerConfigurator configurator, bool initFromConfigFile = false, string sectionName = null)
     where TObjectContainer : IObjectContainer
 {
     return(new ObjectContainerConfigurator(configurator, typeof(TObjectContainer), initFromConfigFile, sectionName));
 }
Пример #3
0
 /// <summary>
 /// Adds an exception handler to the Apworks framework.
 /// </summary>
 /// <typeparam name="TException">The type of the exception to be handled.</typeparam>
 /// <typeparam name="TExceptionHandler">The type of the exception handler.</typeparam>
 /// <param name="configurator">The <see cref="IExceptionHandlerConfigurator"/> to be extended.</param>
 /// <param name="behavior">The exception handling behavior.</param>
 /// <returns>The <see cref="IExceptionHandlerConfigurator"/> instance.</returns>
 public static IExceptionHandlerConfigurator AddExceptionHandler <TException, TExceptionHandler>(this IExceptionHandlerConfigurator configurator, ExceptionHandlingBehavior behavior = ExceptionHandlingBehavior.Direct)
     where TException : Exception
     where TExceptionHandler : IExceptionHandler
 {
     return(new ExceptionHandlerConfigurator(configurator, typeof(TException), typeof(TExceptionHandler), behavior));
 }
Пример #4
0
 /// <summary>
 /// Registers an interceptor on the given method of a given type.
 /// </summary>
 /// <typeparam name="TInterceptor">The type of the interceptor to be registered.</typeparam>
 /// <typeparam name="TContract">The type which contains the method to be intercepted.</typeparam>
 /// <param name="configurator">The <see cref="IExceptionHandlerConfigurator"/> instance to be extended.</param>
 /// <param name="interceptMethod">The method to be intercepted.</param>
 /// <returns>The <see cref="IInterceptionConfigurator"/> instance.</returns>
 public static IInterceptionConfigurator RegisterInterception <TInterceptor, TContract>(this IExceptionHandlerConfigurator configurator, string interceptMethod)
     where TInterceptor : IInterceptor
 {
     return(new InterceptionConfigurator(configurator, typeof(TInterceptor), typeof(TContract), interceptMethod));
 }
 /// <summary>
 /// 通过使用Autofac作为对象容器来配置OFoods框架.
 /// </summary>
 public static IObjectContainerConfigurator UseAutofacContainer(this IExceptionHandlerConfigurator configurator, bool initFromConfigFile = false, string configPath = null)
 {
     return(configurator.UsingObjectContainer <AutofacObjectContainer>(initFromConfigFile, configPath));
 }