public void CanSetUsage()
 {
     var hbmCache = new HbmCache();
     var mapper = new CacheMapper(hbmCache);
     mapper.Usage(CacheUsage.ReadWrite);
     hbmCache.usage.Should().Be(HbmCacheUsage.ReadWrite);
 }
 public void CanSetRegion()
 {
     var hbmCache = new HbmCache();
     var mapper = new CacheMapper(hbmCache);
     mapper.Region("pizza");
     hbmCache.region.Should().Be("pizza");
 }
 public void CanSetInclude()
 {
     var hbmCache = new HbmCache();
     var mapper = new CacheMapper(hbmCache);
     mapper.Include(CacheInclude.NonLazy);
     hbmCache.include.Should().Be(HbmCacheInclude.NonLazy);
 }
Beispiel #4
0
 private static void BindCache(HbmCache cacheSchema, RootClass rootClass)
 {
     if (cacheSchema != null)
     {
         rootClass.CacheConcurrencyStrategy = cacheSchema.usage.ToCacheConcurrencyStrategy();
         rootClass.CacheRegionName = cacheSchema.region;
     }
 }
 public CacheMapper(HbmCache cacheMapping)
 {
     if (cacheMapping == null)
     {
         throw new ArgumentNullException("cacheMapping");
     }
     this.cacheMapping = cacheMapping;
     Usage(CacheUsage.Transactional);
 }
 public void Cache(Action<ICacheMapper> cacheMapping)
 {
     if (cacheMapper == null)
     {
         var hbmCache = new HbmCache();
         classMapping.cache = hbmCache;
         cacheMapper = new CacheMapper(hbmCache);
     }
     cacheMapping(cacheMapper);
 }
Beispiel #7
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);
        }
		private static void BindCache(HbmCache cacheSchema, Mapping.Collection collection)
		{
			if (cacheSchema != null)
			{
				collection.CacheConcurrencyStrategy = cacheSchema.usage.ToCacheConcurrencyStrategy();
				collection.CacheRegionName = cacheSchema.region;
			}
		}
 public void WhenCreatedThenAutoAssignUsage()
 {
     var hbmCache = new HbmCache();
     new CacheMapper(hbmCache);
     hbmCache.usage.Should().Be(HbmCacheUsage.Transactional);
 }
		private static void BindCache(HbmCache cacheSchema, RootClass rootClass)
		{
			if (cacheSchema != null)
			{
				rootClass.CacheConcurrencyStrategy = GetXmlEnumAttribute(cacheSchema.usage);
				rootClass.CacheRegionName = cacheSchema.region;
			}
		}