예제 #1
0
 public static void CheckCacheInfo(DocumentCacheInfo cacheInfo)
 {
     if (cacheInfo == null)
     {
         throw new InvalidOperationException("Document was not found in the cache");
     }
 }
        public CheckCacheInfoResponse CheckCacheInfo(CheckCacheInfoRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            var cache = ServiceHelper.Cache;
            DocumentCacheInfo cacheInfo = DocumentFactory.GetDocumentCacheInfo(cache, request.Uri.ToString());

            if (cacheInfo == null)
            {
                return(new CheckCacheInfoResponse());
            }

            var documentMimeType = cacheInfo.MimeType;
            var status           = DocumentFactory.MimeTypes.GetStatus(documentMimeType);
            var isAccepted       = status != DocumentMimeTypeStatus.Denied;

            var serviceCacheInfo = new CacheInfo
            {
                IsVirtual          = cacheInfo.IsVirtual,
                IsLoaded           = cacheInfo.IsLoaded,
                HasAnnotations     = cacheInfo.HasAnnotations,
                Name               = cacheInfo.Name,
                MimeType           = documentMimeType,
                IsMimeTypeAccepted = isAccepted,
                PageCount          = cacheInfo.PageCount
            };

            return(new CheckCacheInfoResponse
            {
                CacheInfo = serviceCacheInfo
            });
        }