예제 #1
0
        public IDao GetDao(string factoryName)
        {
            if (Daos.ContainsKey(factoryName))
            {
#if DEBUG_SESSIONCONTEXT
                Debug.WriteLine("获取Dao:{0}", Daos[factoryName].GetHashCode());
#endif
                return Daos[factoryName];
            }
            else
            {
              
                IDaoFactory daoFactory = daoFactories.First(dao => dao.FactoryName == factoryName);
                            
                IDao dao  = daoFactory.CreateDao(this);              

                Daos.Add(factoryName, dao);

                CreateDaoEvent?.Invoke(dao);

#if DEBUG_SESSIONCONTEXT
                Debug.WriteLine($"创建并获取Dao:{dao.GetHashCode()} -{Thread.CurrentThread.ManagedThreadId}" );
#endif
                return dao;
            }
        }