Ejemplo n.º 1
0
 public virtual T Get(int?id)
 {
     if ((id ?? 0) == 0)
     {
         return(null);
     }
     return(_dao.Load(id.Value));
 }
Ejemplo n.º 2
0
        public void UseMethodInfoForKeyGeneration()
        {
            ICache cache = new NonExpiringCache();

            context.ObjectFactory.RegisterSingleton("defaultCache", cache);

            ProxyFactory pf = new ProxyFactory(new GenericDao <string, int>());

            pf.AddAdvisors(cacheAspect);

            IGenericDao <string, int> dao = (IGenericDao <string, int>)pf.GetProxy();

            Assert.AreEqual(0, cache.Count);

            dao.Load(1);
            Assert.AreEqual(1, cache.Count);

            // actually, it should be null, because default(string) = null
            // but it returns the NullValue marker created by the CacheResultAttribute
            Assert.IsNotNull(cache.Get("String_1"));
        }