Ejemplo n.º 1
0
        /// Job (JobEnum) need to be defined in the context
        /// </summary>
        /// <param name="job"></param>
        /// <returns></returns>
        public IRepository <T> GetDao(string DaoTypeName, DataSourceParams dataSource)
        {
            IRepository <T> _dao = null;

            object[] args = { dataSource };  // For parametered Constructor

            try
            {
                Type t = Type.GetType(DaoTypeName);
                _dao = (IRepository <T>)Activator.CreateInstance(t, args);
                //_dao = Activator.CreateInstance(t,
                //    BindingFlags.NonPublic | BindingFlags.Instance, null,
                //    args, null) as IDataAccessObject<T>;

                /* parameterless
                 * _job = (IJob)Activator.CreateInstance(Type.GetType(job.Description));
                 */
            }
            catch (TargetInvocationException e)
            {
                throw new SystemException(e.InnerException.Message, e.InnerException);
            }

            return(_dao);
        }
Ejemplo n.º 2
0
 public DataSource(DataSourceParams dataSourceParams)
 {
     _dsParams = dataSourceParams;
     _conn     = new Lazy <IDbConnection>(() =>
     {
         //////return (IDbConnection)((ICloneable)DbConnectionFactory.Instance.GetConnection(_dataSouceSetting.DbConnectionTypeName)).Clone();
         return(DbConnectionFactory.Instance.GetConnection(_dsParams.DbConnectionType));
     });
 }
Ejemplo n.º 3
0
        protected Lazy <IDataSource> _dataSource; // = new Lazy<IDbConnection>(() => DbConnectionFactory.Instance.GetConnection(_dataSourceName));
        #endregion

        #region Constructors
        /// <summary>
        /// Inject DbConnection to DAO
        /// </summary>
        /// <param name=""></param>
        protected DaoBase(DataSourceParams dataSource)
        {
            _dataSource = new Lazy <IDataSource>(() => new DataSource(dataSource));
        }