Beispiel #1
0
        /// <summary>Creates a package reader for a package without accessing the store.</summary>
        /// <param name="file">The package.</param>
        /// <param name="location">The package location.</param>
        /// <param name="runWithElevatedPrivileges">Whether to run with elevated privileges or not.</param>
        public PackageReader CreatePackageReader(SPFile file, SharePointFileLocation location, bool runWithElevatedPrivileges)
        {
            if (SPContentTypeId.FindCommonParent(file.Item.ContentType.Id, permanentCacheContentType) == permanentCacheContentType)
            {
                object directoryValue = file.Item[new Guid("a76de874-b256-4fd6-8933-813aa8587163")];
                if (directoryValue == null)
                {
                    throw new CacheException(Resources.PermanentCacheNoDirectory);
                }
                else
                {
                    DirectoryInfo directory;
                    try
                    {
                        directory = new DirectoryInfo(directoryValue.ToString());
                    }
                    catch (ArgumentException)
                    {
                        throw new CacheException(Resources.PermanentCacheInvalidDirectory);
                    }
                    catch (PathTooLongException)
                    {
                        throw new CacheException(Resources.PermanentCacheInvalidDirectory);
                    }

                    return(new PermanentCacheSharePointPackageReader(directory, location));
                }
            }
            else
            {
                return(new SharePointPackageReader(CacheSettings, location, file, runWithElevatedPrivileges));
            }
        }