Beispiel #1
0
 public IObjectDAO <T> GetObjectDAO <T>()
 {
     if (daoCache.ContainsKey(typeof(T)))
     {
         return((IObjectDAO <T>)daoCache[typeof(T)]);
     }
     foreach (PropertyInfo property in typeof(DAOFactory).GetProperties())
     {
         if (typeof(IObjectDAO <T>).IsAssignableFrom(property.PropertyType))
         {
             IObjectDAO <T> dao = (IObjectDAO <T>)property.GetValue(this, null);
             daoCache[typeof(T)] = dao;
             return(dao);
         }
     }
     daoCache[typeof(T)] = null;
     return(null);
 }
Beispiel #2
0
        public IObjectDAO GetObjectDAO(Type objectType)
        {
            if (daoCache.ContainsKey(objectType))
            {
                return((IObjectDAO)daoCache[objectType]);
            }
            Type objectDAOType = typeof(IObjectDAO <>).MakeGenericType(objectType);

            foreach (PropertyInfo property in typeof(DAOFactory).GetProperties())
            {
                if (objectDAOType.IsAssignableFrom(property.PropertyType))
                {
                    IObjectDAO dao = (IObjectDAO)property.GetValue(this, null);
                    daoCache[objectType] = dao;
                    return(dao);
                }
            }
            daoCache[objectType] = null;
            return(null);
        }