Exemplo n.º 1
0
 /// <summary>
 /// Adds a message handler to the Apworks framework. (This operation only applies on CQRS architecture).
 /// </summary>
 /// <param name="configurator">The <see cref="ISequenceGeneratorConfigurator"/> instance to be extended.</param>
 /// <param name="handlerKind">The <see cref="HandlerKind"/> which specifies the kind of the handler, can either be a Command or an Event.</param>
 /// <param name="sourceType">The <see cref="HandlerSourceType"/> which specifies the type of the source, can either be an Assembly or a Type.</param>
 /// <param name="source">The source name, if <paramref name="sourceType"/> is Assembly, the source name should be the assembly full name, if
 /// <paramref name="sourceType"/> is Type, the source name should be the assembly qualified name of the type.</param>
 /// <param name="name">The name of the message handler.</param>
 /// <returns>The <see cref="IHandlerConfigurator"/> instance.</returns>
 public static IHandlerConfigurator AddMessageHandler(this ISequenceGeneratorConfigurator configurator, HandlerKind handlerKind, HandlerSourceType sourceType, string source, string name = null)
 {
     if (string.IsNullOrEmpty(name))
     {
         return(new HandlerConfigurator(configurator, handlerKind, sourceType, source));
     }
     else
     {
         return(new HandlerConfigurator(configurator, name, handlerKind, sourceType, source));
     }
 }
 /// <summary>
 /// Configures the Apworks framework by using Unity as the object container.
 /// </summary>
 /// <param name="configurator">The <see cref="ISequenceGeneratorConfigurator"/> 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 ISequenceGeneratorConfigurator configurator, bool initFromConfigFile = false, string sectionName = null)
 {
     return(configurator.UsingObjectContainer <UnityObjectContainer>(initFromConfigFile, sectionName));
 }
Exemplo n.º 3
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="ISequenceGeneratorConfigurator"/> 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 ISequenceGeneratorConfigurator configurator, bool initFromConfigFile = false, string sectionName = null)
     where TObjectContainer : IObjectContainer
 {
     return(new ObjectContainerConfigurator(configurator, typeof(TObjectContainer), initFromConfigFile, sectionName));
 }
Exemplo n.º 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="ISequenceGeneratorConfigurator"/> 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 ISequenceGeneratorConfigurator configurator, string interceptMethod)
     where TInterceptor : IInterceptor
 {
     return(new InterceptionConfigurator(configurator, typeof(TInterceptor), typeof(TContract), interceptMethod));
 }
Exemplo n.º 5
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="ISequenceGeneratorConfigurator"/> 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 ISequenceGeneratorConfigurator configurator, ExceptionHandlingBehavior behavior = ExceptionHandlingBehavior.Direct)
     where TException : Exception
     where TExceptionHandler : IExceptionHandler
 {
     return(new ExceptionHandlerConfigurator(configurator, typeof(TException), typeof(TExceptionHandler), behavior));
 }
 /// <summary>
 /// 通过使用Autofac作为对象容器来配置OFoods框架.
 /// </summary>
 public static IObjectContainerConfigurator UseAutofacContainer(this ISequenceGeneratorConfigurator configurator, bool initFromConfigFile = false, string configPath = null)
 {
     return(configurator.UsingObjectContainer <AutofacObjectContainer>(initFromConfigFile, configPath));
 }