Registration of the BO Classes

By default, Xafari uses reflection to find all classes of the Business Operations and Implementations in all modules referenced by the app.However, the developer has the ability to register these classes in the custom module explicitly. This way helps to optimize the initialization time because it does not use reflection to find the necessary classes.

To declare the Business Operations and Implementations explicitly, there is the important requirement the module class must satisfy: it should implement ITypesProvider<IBusinessOperation> and ITypesProvider<IOperationService> interfaces. ITypesProvider<T> interface declares GetTypes() method which returns IEnumerable<Type> collection. Each returned type is a heir of the Type specified as a generic argument. The code snippet below shows the explicid declaratiom of the Business Operations and Implementation.

  • c#
  • c#(original)

public sealed partial class MyModule : ModuleBase, ITypesProvider<IBusinessOperation>, ITypesProvider<IOperationService>
{
  /// <summary>
  /// Business Operations of current module.
  /// </summary>
  IEnumerable<Type> ITypesProvider<IBusinessOperation>.GetTypes()
  {
    return new [] { typeof(CalcOrderTotal) };
  }
  /// <summary>
  /// Business Operation Services of current module.
  /// </summary>
  IEnumerable<Type> ITypesProvider<IOperationService>.GetTypes()
  {
    return new [] { typeof(CalcWithoutDiscount), typeof(CalcWithDiscount) };
  }
}

public sealed partial class MyModule : ModuleBase, ITypesProvider<IBusinessOperation>, ITypesProvider<IOperationService>
 {
 /// <summary>
 /// Business Operations of current module.
 /// </summary>
 IEnumerable<Type> ITypesProvider<IBusinessOperation>.GetTypes()
 {
     return new[]
     {
      typeof (CalcOrderTotal)
     };
 }

 /// <summary>
 /// Business Operation Services of current module.
 /// </summary>
 IEnumerable<Type> ITypesProvider<IOperationService>.GetTypes()
 {
     return new[]
     {
      typeof (CalcWithoutDiscount),
      typeof (CalcWithDiscount),
     };
 }
 }