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)); }
/// <summary> /// Test whether or not an Entity's publishing state is visible in the current context. /// </summary> public virtual bool TryAssert(OrganizationServiceContext context, Entity entity) { var securityContextKey = GetType().FullName; ICacheSupportingCrmEntitySecurityProvider underlyingProvider = new ApplicationCachingCrmEntitySecurityProvider(new UncachedProvider(), new VaryByPreviewCrmEntitySecurityCacheInfoFactory(securityContextKey)); if (HttpContext.Current != null) { underlyingProvider = new RequestCachingCrmEntitySecurityProvider(underlyingProvider, new CrmEntitySecurityCacheInfoFactory(securityContextKey)); } return(underlyingProvider.TryAssert(context, entity, CrmEntityRight.Read)); }