Ejemplo n.º 1
0
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]   // this method does significant work
        public Stream GetFileStream()
        {
            CheckDisposed();

            // Get the stream while running in elevated privileges mode.
            string cacheDir = CachedPackage.CacheDir;

            SetFileName(cacheDir);
            return(FileSystemPackageReader.ReadFile(cacheDir, FileName, m_settings.ImpersonationBehavior));
        }
        FileSystemPackageReader m_fsPackageReader;  // the PackageReader to read resource files

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="packageBasePath">The absolute path to the location where the packages
        /// are located in the filesystem.</param>
        /// <param name="packageStore">The PackageStore that contains information about the package.</param>
        /// <param name="packageId">The package id of the package to load.</param>
        /// <param name="packageLocation">The location of the package, as defined in
        /// LearningStore PackageItem.Location column. This cannot be null.</param>
        /// <param name="impersonationBehavior">The user who has access to the file system related to the store.</param>
        /// <remarks></remarks>
        internal FileSystemPackageStoreReader(string packageBasePath, FileSystemPackageStore packageStore,
                                              PackageItemIdentifier packageId, string packageLocation, ImpersonationBehavior impersonationBehavior)
        {
            m_store                 = packageStore;
            m_packageId             = packageId;
            m_impersonationBehavior = impersonationBehavior;

            m_packageBasePath = PackageReader.SafePathCombine(packageBasePath, packageLocation);

            // This does not verify that m_packageBasePath actually exists
            m_fsPackageReader = new FileSystemPackageReader(m_packageBasePath, m_impersonationBehavior);
        }
 /// <summary>
 /// Releases all resources used by this object
 /// </summary>
 /// <param name="disposing">True if this method was called from
 ///    <Typ>/System.IDisposable.Dispose</Typ></param>
 protected override void Dispose(bool disposing)
 {
     try
     {
         if (m_fsPackageReader != null)
         {
             m_fsPackageReader.Dispose();
             m_fsPackageReader = null;
         }
     }
     finally
     {
         base.Dispose(disposing);
     }
 }
 /// <summary>
 /// Releases all resources used by this object
 /// </summary>
 /// <param name="disposing">True if this method was called from
 ///    <Typ>/System.IDisposable.Dispose</Typ></param>
 protected override void Dispose(bool disposing)
 {
     m_disposed = true;
     try
     {
         if (fileSystemPackageReader != null)
         {
             fileSystemPackageReader.Dispose();
             fileSystemPackageReader = null;
         }
     }
     finally
     {
         base.Dispose(disposing);
     }
 }
Ejemplo n.º 5
0
        public override PackageReader GetPackageReader()
        {
            var reader = new FileSystemPackageReader(FolderPath);

            return(reader);
        }