예제 #1
0
        private bool TryAssert()
        {
            var cacheKeyFactory = new CrmEntitySecurityCacheInfoFactory(GetType().FullName);

            ICacheSupportingCrmEntitySecurityProvider provider = new ApplicationCachingCrmEntitySecurityProvider(new PreviewPermissionProvider(), cacheKeyFactory);

            if (_context != null)
            {
                provider = new RequestCachingCrmEntitySecurityProvider(provider, cacheKeyFactory);
            }

            return(provider.TryAssert(ServiceContext, _website, CrmEntityRight.Read));
        }
예제 #2
0
        public override void Initialize(string name, NameValueCollection config)
        {
            base.Initialize(name, config);

            var portalName = config["portalName"];

            var contentMapProvider = AdxstudioCrmConfigurationManager.CreateContentMapProvider(portalName);

            _underlyingProvider = contentMapProvider != null
                                ? new ContentMapUncachedProvider(contentMapProvider)
                                : new UncachedProvider(portalName);

            var cacheInfoFactory = new CrmEntitySecurityCacheInfoFactory(GetType().FullName);

            bool cachingEnabled;

            if (!bool.TryParse(config["cachingEnabled"], out cachingEnabled))
            {
                cachingEnabled = true;
            }

            if (cachingEnabled)
            {
                _underlyingProvider = new ApplicationCachingCrmEntitySecurityProvider(_underlyingProvider, cacheInfoFactory);
            }

            bool requestCachingEnabled;

            if (!bool.TryParse(config["requestCachingEnabled"], out requestCachingEnabled))
            {
                requestCachingEnabled = true;
            }

            if (requestCachingEnabled && HttpContext.Current != null)
            {
                _underlyingProvider = new RequestCachingCrmEntitySecurityProvider(_underlyingProvider, cacheInfoFactory);
            }
        }