Пример #1
0
 private static LogicFactory CreateLogicFactory(BusinessLogicType type)
 {
     switch (type)
     {
     case BusinessLogicType.Poco:
         return(new PocoLogicFactory());
     }
     throw new ArgumentException("Business logic factory for type " + type +
                                 " is not implemented. Check the switch in HaaSMiddleware.BusinessLogicTier.Factory.AbstracLogicFactory.CreateLogicFactory(BusinessLogicType type) method.");
 }
Пример #2
0
 public static LogicFactory GetLogicFactory(BusinessLogicType type)
 {
     lock (factoryInstances)
     {
         if (!factoryInstances.ContainsKey(type))
         {
             factoryInstances.Add(type, CreateLogicFactory(type));
         }
     }
     return(factoryInstances[type]);
 }
        /// <summary>
        /// Initializes the <see cref="BusinessLogic"/> with the wanted <see cref="StrategyType"/> and <see cref="DatabaseType"/>.
        /// Note that this method gets triggered before the view gets initialized in <see cref="Program"/>.
        /// </summary>
        /// <param name="strategyType"></param>
        /// <param name="dbType"></param>
        public static void SetStrategyAndDatabaseType(BusinessLogicType blType, DatabaseType dbType, SortType sortType)
        {
            switch (blType)
            {
            case BusinessLogicType.Normal: @default:
                BusinessLogic = new BusinessLogic(dbType, sortType);
                break;

            case BusinessLogicType.MultiThreaded:
                BusinessLogic = new BusinessLogicMt(dbType, sortType);
                break;

            default:
                goto @default;
            }
        }
Пример #4
0
        /// <summary>
        /// Parses the <see cref="StrategyType"/> argument for modifying the <see cref="_strategyType"/> before the main
        /// initializes the database and strategy type.
        /// </summary>
        /// <param name="arg">The <see cref="StrategyType"/> argument that is passed from the console. </param>
        /// <returns>Returns false if parse failed, true if successful. </returns>
        private static bool ParseBusinessLogicTypeArg(string arg)
        {
            switch (arg)
            {
            case "/b":
                Log.Info("Using BusinessLogicType.Normal.");
                _businessLogicType = BusinessLogicType.Normal;
                return(true);

            case "/b-mt":
                Log.Info("Using BusinessLogicType.MultiThreaded.");
                _businessLogicType = BusinessLogicType.MultiThreaded;
                return(true);

            default:
                InvalidSyntax();
                return(false);
            }
        }