示例#1
0
 public IObjectViewDAO <T> GetObjectViewDAO <T>() where T : new()
 {
     if (viewDAOCache.ContainsKey(typeof(T)))
     {
         return((IObjectViewDAO <T>)viewDAOCache[typeof(T)]);
     }
     foreach (PropertyInfo property in typeof(DAOFactory).GetProperties())
     {
         if (typeof(IObjectViewDAO <T>).IsAssignableFrom(property.PropertyType))
         {
             IObjectViewDAO <T> viewDAO = (IObjectViewDAO <T>)property.GetValue(this, null);
             viewDAOCache[typeof(T)] = viewDAO;
             return(viewDAO);
         }
     }
     viewDAOCache[typeof(T)] = null;
     return(null);
 }
示例#2
0
        public IObjectViewDAO GetObjectViewDAO(Type objectType)
        {
            if (viewDAOCache.ContainsKey(objectType))
            {
                return((IObjectViewDAO)viewDAOCache[objectType]);
            }
            Type objectDAOType = typeof(IObjectViewDAO <>).MakeGenericType(objectType);

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