Beispiel #1
0
        public void WhenCreatedThenAutoAssignUsage()
        {
            var hbmCache = new HbmCache();

            new CacheMapper(hbmCache);
            hbmCache.usage.Should().Be(HbmCacheUsage.Transactional);
        }
Beispiel #2
0
        public void Add(HbmCache cache, bool body = false)
        {
            if (cache == null)
            {
                return;
            }

            string region = "";

            if (cache.region != null)
            {
                region = string.Format(".Region(\"{0}\")", cache.region);
            }

            string cacheStr = string.Format("Cache.{0}(){1}", cache.usage == HbmCacheUsage.NonstrictReadWrite? "NonStrictReadWrite" : cache.usage.ToString(), region);

            if (body)
            {
                cacheStr = cacheStr + ";";
            }
            else
            {
                cacheStr = "." + cacheStr;
            }

            _builder.AddLine(cacheStr);
        }
Beispiel #3
0
 private static void BindCache(HbmCache cacheSchema, RootClass rootClass)
 {
     if (cacheSchema != null)
     {
         rootClass.CacheConcurrencyStrategy = GetXmlEnumAttribute(cacheSchema.usage);
         rootClass.CacheRegionName          = cacheSchema.region;
     }
 }
Beispiel #4
0
 private static void BindCache(HbmCache cacheSchema, Mapping.Collection collection)
 {
     if (cacheSchema != null)
     {
         collection.CacheConcurrencyStrategy = cacheSchema.usage.ToCacheConcurrencyStrategy();
         collection.CacheRegionName          = cacheSchema.region;
     }
 }
Beispiel #5
0
        public void CanSetInclude()
        {
            var hbmCache = new HbmCache();
            var mapper   = new CacheMapper(hbmCache);

            mapper.Include(CacheInclude.NonLazy);
            hbmCache.include.Should().Be(HbmCacheInclude.NonLazy);
        }
Beispiel #6
0
        public void CanSetRegion()
        {
            var hbmCache = new HbmCache();
            var mapper   = new CacheMapper(hbmCache);

            mapper.Region("pizza");
            hbmCache.region.Should().Be("pizza");
        }
Beispiel #7
0
        public void CanSetUsage()
        {
            var hbmCache = new HbmCache();
            var mapper   = new CacheMapper(hbmCache);

            mapper.Usage(CacheUsage.ReadWrite);
            hbmCache.usage.Should().Be(HbmCacheUsage.ReadWrite);
        }
Beispiel #8
0
 private static void BindCache(HbmCache cacheSchema, RootClass rootClass)
 {
     if (cacheSchema != null)
     {
         rootClass.CacheConcurrencyStrategy = cacheSchema.usage.ToCacheConcurrencyStrategy();
         rootClass.CacheRegionName          = cacheSchema.region;
     }
 }
Beispiel #9
0
 public CacheMapper(HbmCache cacheMapping)
 {
     if (cacheMapping == null)
     {
         throw new ArgumentNullException("cacheMapping");
     }
     this.cacheMapping = cacheMapping;
     Usage(CacheUsage.Transactional);
 }
Beispiel #10
0
 private static void BindCache(HbmCache cacheSchema, RootClass rootClass)
 {
     if (cacheSchema != null)
     {
         rootClass.CacheConcurrencyStrategy = cacheSchema.usage.ToCacheConcurrencyStrategy();
         rootClass.CacheRegionName          = cacheSchema.region;
         rootClass.SetLazyPropertiesCacheable(cacheSchema.include == HbmCacheInclude.All);
     }
 }
Beispiel #11
0
 public void Cache(Action <ICacheMapper> cacheMapping)
 {
     if (cacheMapper == null)
     {
         var hbmCache = new HbmCache();
         mapping.cache = hbmCache;
         cacheMapper   = new CacheMapper(hbmCache);
     }
     cacheMapping(cacheMapper);
 }