Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Base / System / IO / Packaging / ZipPackagePart.cs / 1 / ZipPackagePart.cs
//------------------------------------------------------------------------------ // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // Description: // This is a subclass for the abstract PackagePart class. // This implementation is specific to Zip file format. // // History: // 12/28/2004: SarjanaS: Initial creation. [BruceMac provided some of the // initial code] // //----------------------------------------------------------------------------- using System; using System.Collections.Generic; using MS.Internal.IO.Zip; using MS.Internal.IO.Packaging; using MS.Internal; // for Invariant namespace System.IO.Packaging { ////// This class represents a Part within a Zip container. /// This is a part of the Packaging Layer APIs /// public sealed class ZipPackagePart : PackagePart { //----------------------------------------------------- // // Public Constructors // //----------------------------------------------------- // None //------------------------------------------------------ // // Public Properties // //----------------------------------------------------- // None //------------------------------------------------------ // // Public Methods // //------------------------------------------------------ #region Public Methods ////// Custom Implementation for the GetStream Method /// /// Mode in which the stream should be opened /// Access with which the stream should be opened ///Stream Corresponding to this part protected override Stream GetStreamCore(FileMode mode, FileAccess access) { if (Package.InStreamingCreation) { // Convert Metro CompressionOption to Zip CompressionMethodEnum. CompressionMethodEnum compressionMethod; DeflateOptionEnum deflateOption; ZipPackage.GetZipCompressionMethodFromOpcCompressionOption(this.CompressionOption, out compressionMethod, out deflateOption); // Mode and access get validated in StreamingZipPartStream(). return new StreamingZipPartStream( PackUriHelper.GetStringForPartUri(this.Uri), _zipArchive, compressionMethod, deflateOption, mode, access); } else if (_zipFileInfo != null) { // Case of an atomic part. return _zipFileInfo.GetStream(mode, access); } else { // Case of an interleaved part. Invariant.Assert(_pieces != null); return new InterleavedZipPartStream(this, mode, access); } } #endregion Public Methods //----------------------------------------------------- // // Public Events // //------------------------------------------------------ // None //----------------------------------------------------- // // Internal Constructors // //----------------------------------------------------- #region Internal Constructors ////// Constructs a ZipPackagePart for an atomic (i.e. non-interleaved) part. /// This is called from the ZipPackage class as a result of GetPartCore, /// GetPartsCore or CreatePartCore methods /// /// /// /// /// /// internal ZipPackagePart(ZipPackage container, ZipFileInfo zipFileInfo, PackUriHelper.ValidatedPartUri partUri, string contentType, CompressionOption compressionOption) :base(container, partUri, contentType, compressionOption) { _zipArchive = zipFileInfo.ZipArchive; _zipFileInfo = zipFileInfo; } ////// Constructs a ZipPackagePart. This is called from ZipPackage.CreatePartCore in streaming /// production. /// No piece is created until the first write operation on the associated stream. Therefore /// this constructor does not take a ZipFileInfo. /// /// /// /// /// /// internal ZipPackagePart(ZipPackage container, ZipArchive zipArchive, PackUriHelper.ValidatedPartUri partUri, string contentType, CompressionOption compressionOption) :base(container, partUri, contentType, compressionOption) { _zipArchive = zipArchive; } ////// Constructs a ZipPackagePart for an interleaved part. This is called outside of streaming /// production when an interleaved part is encountered in the package. /// /// /// /// /// /// /// internal ZipPackagePart(ZipPackage container, ZipArchive zipArchive, Listpieces, PackUriHelper.ValidatedPartUri partUri, string contentType, CompressionOption compressionOption) :base(container, partUri, contentType, compressionOption) { _zipArchive = zipArchive; _pieces = pieces; } #endregion Internal Constructors //----------------------------------------------------- // // Internal Properties // //------------------------------------------------------ #region Internal Properties /// /// Obtain the sorted array of piece descriptors for an interleaved part. /// internal ListPieceDescriptors { get { return _pieces; } } /// /// Obtain the ZipFileInfo descriptor of an atomic part. /// internal ZipFileInfo ZipFileInfo { get { return _zipFileInfo; } } #endregion Internal Properties //----------------------------------------------------- // // Internal Methods // //------------------------------------------------------ // None //------------------------------------------------------ // // Internal Events // //----------------------------------------------------- // None //------------------------------------------------------ // // Private Methods // //----------------------------------------------------- // None //----------------------------------------------------- // // Private Fields // //----------------------------------------------------- #region Private Variables // Zip item info for an atomic part. private ZipFileInfo _zipFileInfo; // Piece descriptors for an interleaved part. private List_pieces; //ZipArhive private ZipArchive _zipArchive; #endregion Private Variables //------------------------------------------------------ } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //------------------------------------------------------------------------------ // // // Copyright (C) Microsoft Corporation. All rights reserved. // // // Description: // This is a subclass for the abstract PackagePart class. // This implementation is specific to Zip file format. // // History: // 12/28/2004: SarjanaS: Initial creation. [BruceMac provided some of the // initial code] // //----------------------------------------------------------------------------- using System; using System.Collections.Generic; using MS.Internal.IO.Zip; using MS.Internal.IO.Packaging; using MS.Internal; // for Invariant namespace System.IO.Packaging { ////// This class represents a Part within a Zip container. /// This is a part of the Packaging Layer APIs /// public sealed class ZipPackagePart : PackagePart { //----------------------------------------------------- // // Public Constructors // //----------------------------------------------------- // None //------------------------------------------------------ // // Public Properties // //----------------------------------------------------- // None //------------------------------------------------------ // // Public Methods // //------------------------------------------------------ #region Public Methods ////// Custom Implementation for the GetStream Method /// /// Mode in which the stream should be opened /// Access with which the stream should be opened ///Stream Corresponding to this part protected override Stream GetStreamCore(FileMode mode, FileAccess access) { if (Package.InStreamingCreation) { // Convert Metro CompressionOption to Zip CompressionMethodEnum. CompressionMethodEnum compressionMethod; DeflateOptionEnum deflateOption; ZipPackage.GetZipCompressionMethodFromOpcCompressionOption(this.CompressionOption, out compressionMethod, out deflateOption); // Mode and access get validated in StreamingZipPartStream(). return new StreamingZipPartStream( PackUriHelper.GetStringForPartUri(this.Uri), _zipArchive, compressionMethod, deflateOption, mode, access); } else if (_zipFileInfo != null) { // Case of an atomic part. return _zipFileInfo.GetStream(mode, access); } else { // Case of an interleaved part. Invariant.Assert(_pieces != null); return new InterleavedZipPartStream(this, mode, access); } } #endregion Public Methods //----------------------------------------------------- // // Public Events // //------------------------------------------------------ // None //----------------------------------------------------- // // Internal Constructors // //----------------------------------------------------- #region Internal Constructors ////// Constructs a ZipPackagePart for an atomic (i.e. non-interleaved) part. /// This is called from the ZipPackage class as a result of GetPartCore, /// GetPartsCore or CreatePartCore methods /// /// /// /// /// /// internal ZipPackagePart(ZipPackage container, ZipFileInfo zipFileInfo, PackUriHelper.ValidatedPartUri partUri, string contentType, CompressionOption compressionOption) :base(container, partUri, contentType, compressionOption) { _zipArchive = zipFileInfo.ZipArchive; _zipFileInfo = zipFileInfo; } ////// Constructs a ZipPackagePart. This is called from ZipPackage.CreatePartCore in streaming /// production. /// No piece is created until the first write operation on the associated stream. Therefore /// this constructor does not take a ZipFileInfo. /// /// /// /// /// /// internal ZipPackagePart(ZipPackage container, ZipArchive zipArchive, PackUriHelper.ValidatedPartUri partUri, string contentType, CompressionOption compressionOption) :base(container, partUri, contentType, compressionOption) { _zipArchive = zipArchive; } ////// Constructs a ZipPackagePart for an interleaved part. This is called outside of streaming /// production when an interleaved part is encountered in the package. /// /// /// /// /// /// /// internal ZipPackagePart(ZipPackage container, ZipArchive zipArchive, Listpieces, PackUriHelper.ValidatedPartUri partUri, string contentType, CompressionOption compressionOption) :base(container, partUri, contentType, compressionOption) { _zipArchive = zipArchive; _pieces = pieces; } #endregion Internal Constructors //----------------------------------------------------- // // Internal Properties // //------------------------------------------------------ #region Internal Properties /// /// Obtain the sorted array of piece descriptors for an interleaved part. /// internal ListPieceDescriptors { get { return _pieces; } } /// /// Obtain the ZipFileInfo descriptor of an atomic part. /// internal ZipFileInfo ZipFileInfo { get { return _zipFileInfo; } } #endregion Internal Properties //----------------------------------------------------- // // Internal Methods // //------------------------------------------------------ // None //------------------------------------------------------ // // Internal Events // //----------------------------------------------------- // None //------------------------------------------------------ // // Private Methods // //----------------------------------------------------- // None //----------------------------------------------------- // // Private Fields // //----------------------------------------------------- #region Private Variables // Zip item info for an atomic part. private ZipFileInfo _zipFileInfo; // Piece descriptors for an interleaved part. private List_pieces; //ZipArhive private ZipArchive _zipArchive; #endregion Private Variables //------------------------------------------------------ } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DbParameterHelper.cs
- TemplateManager.cs
- SqlTriggerAttribute.cs
- ByteStreamMessageEncoderFactory.cs
- NonClientArea.cs
- DictionaryEntry.cs
- TextInfo.cs
- RecordManager.cs
- NamespaceImport.cs
- CodeIdentifier.cs
- BitmapPalettes.cs
- RSAOAEPKeyExchangeDeformatter.cs
- NativeMethods.cs
- SmiEventSink_Default.cs
- CodeDelegateCreateExpression.cs
- GridViewDeletedEventArgs.cs
- GridView.cs
- FlowDocumentPage.cs
- EventMappingSettingsCollection.cs
- HierarchicalDataBoundControlAdapter.cs
- EncoderFallback.cs
- SourceInterpreter.cs
- ActivityMarkupSerializer.cs
- PropertyInfoSet.cs
- SelfIssuedTokenFactoryCredential.cs
- ScrollBarAutomationPeer.cs
- VarRefManager.cs
- WebPartsPersonalizationAuthorization.cs
- Interlocked.cs
- OleStrCAMarshaler.cs
- EventProxy.cs
- TargetConverter.cs
- IntranetCredentialPolicy.cs
- ColorAnimationBase.cs
- StateChangeEvent.cs
- StyleTypedPropertyAttribute.cs
- StylusPointPropertyInfoDefaults.cs
- SqlMultiplexer.cs
- PbrsForward.cs
- DashStyles.cs
- ComplexTypeEmitter.cs
- ResourceSet.cs
- XslVisitor.cs
- UserControlAutomationPeer.cs
- DataPagerFieldCommandEventArgs.cs
- Compress.cs
- XmlAtomicValue.cs
- RegexStringValidator.cs
- Rect3DConverter.cs
- UdpDiscoveryMessageFilter.cs
- LinqDataSourceStatusEventArgs.cs
- ScriptServiceAttribute.cs
- MessagePropertyVariants.cs
- exports.cs
- DataServiceContext.cs
- DataSourceCacheDurationConverter.cs
- SqlRowUpdatedEvent.cs
- SafeHandle.cs
- ReceiveActivity.cs
- ProfileGroupSettingsCollection.cs
- ActivityBindForm.Designer.cs
- ConnectionInterfaceCollection.cs
- PackageProperties.cs
- Profiler.cs
- DataGridViewBand.cs
- Size3DConverter.cs
- DrawingAttributeSerializer.cs
- ScrollPatternIdentifiers.cs
- TextTreeInsertUndoUnit.cs
- ColorContextHelper.cs
- Roles.cs
- ReadOnlyHierarchicalDataSourceView.cs
- NullableConverter.cs
- NullableDoubleAverageAggregationOperator.cs
- TraceEventCache.cs
- BoundPropertyEntry.cs
- PathSegment.cs
- IdleTimeoutMonitor.cs
- Baml2006KnownTypes.cs
- SystemInfo.cs
- Decimal.cs
- RequestNavigateEventArgs.cs
- XmlTypeMapping.cs
- HTTP_SERVICE_CONFIG_URLACL_PARAM.cs
- WeakHashtable.cs
- Int64KeyFrameCollection.cs
- CodeEventReferenceExpression.cs
- CompositionDesigner.cs
- IdentityElement.cs
- FileLogRecordHeader.cs
- OdbcEnvironment.cs
- DesignerActionPanel.cs
- WinFormsSecurity.cs
- DependencyPropertyDescriptor.cs
- XmlSchemaDocumentation.cs
- CacheDict.cs
- LinkedList.cs
- PackageDigitalSignature.cs
- SortKey.cs
- BooleanKeyFrameCollection.cs