Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Base / MS / Internal / IO / Packaging / CompoundFile / CompressionTransform.cs / 1 / CompressionTransform.cs
//------------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
// Description:
// This class implements IDataTransform for the Compression transform.
//
// History:
// 06/04/2002: BruceMac: Initial implementation.
// 05/29/2003: LGolding: Ported to WCP tree.
// 05/17/2005: BruceMac: Port to Office-compatible block-based format
// 05/30/2005: BruceMac: Moved to System.IO.Packaging namespace
// 12/14/2005: BruceMac: Moved to MS.Internal.IO.Packaging.CompoundFile namespace
//
//-----------------------------------------------------------------------------
using System;
using System.Collections; // for IDictionary
using System.IO; // for Stream
using System.IO.Packaging;
using System.Globalization; // for CultureInfo
using System.Windows; // ExceptionStringTable
using MS.Internal.IO.Packaging; // CompoundFileEmulationStream
using MS.Internal.IO.Packaging.CompoundFile;
//using System.Windows;
namespace MS.Internal.IO.Packaging.CompoundFile
{
///
/// CompressionTransform for use in Compound File DataSpaces
///
internal class CompressionTransform : IDataTransform
{
#region IDataTransform
///
/// Transform readiness
///
public bool IsReady
{
get
{
return true;
}
}
///
/// No configuration parameters for this transform
///
public bool FixedSettings
{
get
{
return true;
}
}
///
/// Returns the type name identifier string.
///
public object TransformIdentifier
{
get
{
return CompressionTransform.ClassTransformIdentifier;
}
}
///
/// Expose the transform identifier for the use of the DataSpaceManager.
///
internal static string ClassTransformIdentifier
{
get
{
return "{86DE7F2B-DDCE-486d-B016-405BBE82B8BC}";
}
}
//-----------------------------------------------------
//
// Public Methods
//
//-----------------------------------------------------
///
/// Given output stream returns stream for encoding/decoding
///
/// the encoded stream that this transform acts on
/// Dictionary object used to store any additional context information
/// the stream that implements the transform
///
/// This method is used only by the DataSpaceManager, so we declare it as an explicit
/// interface implementation to hide it from the public interface.
///
Stream
IDataTransform.GetTransformedStream(
Stream encodedStream,
IDictionary transformContext
)
{
Stream tempStream = new SparseMemoryStream(_lowWaterMark, _highWaterMark);
tempStream = new CompressEmulationStream(encodedStream, tempStream, 0, new CompoundFileDeflateTransform());
// return a VersionedStream that works with the VersionedStreamOwner
// to verify/update our FormatVersion info
return new VersionedStream(tempStream, _versionedStreamOwner);
}
#endregion
///
/// constructor
///
/// environment
/// this should only be used by the DataSpaceManager class
public CompressionTransform(TransformEnvironment myEnvironment)
{
_transformEnvironment = myEnvironment;
// Create a wrapper that manages persistence and comparison of FormatVersion
// in our InstanceData stream. We can read/write to this stream as needed (though CompressionTransform
// does not because we don't house any non-FormatVersion data in the instance data stream).
// We need to give out our current code version so it can compare with any file version as appropriate.
_versionedStreamOwner = new VersionedStreamOwner(
_transformEnvironment.GetPrimaryInstanceData(),
new FormatVersion(_featureName, _minimumReaderVersion, _minimumUpdaterVersion, _currentFeatureVersion));
}
//------------------------------------------------------
//
// Private Data
//
//-----------------------------------------------------
private TransformEnvironment _transformEnvironment;
private VersionedStreamOwner _versionedStreamOwner; // our instance data stream wrapped
private static readonly string _featureName = "Microsoft.Metadata.CompressionTransform";
private static readonly VersionPair _currentFeatureVersion = new VersionPair(1, 0);
private static readonly VersionPair _minimumReaderVersion = new VersionPair(1, 0);
private static readonly VersionPair _minimumUpdaterVersion = new VersionPair(1, 0);
private const long _lowWaterMark = 0x19000; // we definitely would like to keep everything under 100 KB in memory
private const long _highWaterMark = 0xA00000; // we would like to keep everything over 10 MB on disk
}
}
// 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 class implements IDataTransform for the Compression transform.
//
// History:
// 06/04/2002: BruceMac: Initial implementation.
// 05/29/2003: LGolding: Ported to WCP tree.
// 05/17/2005: BruceMac: Port to Office-compatible block-based format
// 05/30/2005: BruceMac: Moved to System.IO.Packaging namespace
// 12/14/2005: BruceMac: Moved to MS.Internal.IO.Packaging.CompoundFile namespace
//
//-----------------------------------------------------------------------------
using System;
using System.Collections; // for IDictionary
using System.IO; // for Stream
using System.IO.Packaging;
using System.Globalization; // for CultureInfo
using System.Windows; // ExceptionStringTable
using MS.Internal.IO.Packaging; // CompoundFileEmulationStream
using MS.Internal.IO.Packaging.CompoundFile;
//using System.Windows;
namespace MS.Internal.IO.Packaging.CompoundFile
{
///
/// CompressionTransform for use in Compound File DataSpaces
///
internal class CompressionTransform : IDataTransform
{
#region IDataTransform
///
/// Transform readiness
///
public bool IsReady
{
get
{
return true;
}
}
///
/// No configuration parameters for this transform
///
public bool FixedSettings
{
get
{
return true;
}
}
///
/// Returns the type name identifier string.
///
public object TransformIdentifier
{
get
{
return CompressionTransform.ClassTransformIdentifier;
}
}
///
/// Expose the transform identifier for the use of the DataSpaceManager.
///
internal static string ClassTransformIdentifier
{
get
{
return "{86DE7F2B-DDCE-486d-B016-405BBE82B8BC}";
}
}
//-----------------------------------------------------
//
// Public Methods
//
//-----------------------------------------------------
///
/// Given output stream returns stream for encoding/decoding
///
/// the encoded stream that this transform acts on
/// Dictionary object used to store any additional context information
/// the stream that implements the transform
///
/// This method is used only by the DataSpaceManager, so we declare it as an explicit
/// interface implementation to hide it from the public interface.
///
Stream
IDataTransform.GetTransformedStream(
Stream encodedStream,
IDictionary transformContext
)
{
Stream tempStream = new SparseMemoryStream(_lowWaterMark, _highWaterMark);
tempStream = new CompressEmulationStream(encodedStream, tempStream, 0, new CompoundFileDeflateTransform());
// return a VersionedStream that works with the VersionedStreamOwner
// to verify/update our FormatVersion info
return new VersionedStream(tempStream, _versionedStreamOwner);
}
#endregion
///
/// constructor
///
/// environment
/// this should only be used by the DataSpaceManager class
public CompressionTransform(TransformEnvironment myEnvironment)
{
_transformEnvironment = myEnvironment;
// Create a wrapper that manages persistence and comparison of FormatVersion
// in our InstanceData stream. We can read/write to this stream as needed (though CompressionTransform
// does not because we don't house any non-FormatVersion data in the instance data stream).
// We need to give out our current code version so it can compare with any file version as appropriate.
_versionedStreamOwner = new VersionedStreamOwner(
_transformEnvironment.GetPrimaryInstanceData(),
new FormatVersion(_featureName, _minimumReaderVersion, _minimumUpdaterVersion, _currentFeatureVersion));
}
//------------------------------------------------------
//
// Private Data
//
//-----------------------------------------------------
private TransformEnvironment _transformEnvironment;
private VersionedStreamOwner _versionedStreamOwner; // our instance data stream wrapped
private static readonly string _featureName = "Microsoft.Metadata.CompressionTransform";
private static readonly VersionPair _currentFeatureVersion = new VersionPair(1, 0);
private static readonly VersionPair _minimumReaderVersion = new VersionPair(1, 0);
private static readonly VersionPair _minimumUpdaterVersion = new VersionPair(1, 0);
private const long _lowWaterMark = 0x19000; // we definitely would like to keep everything under 100 KB in memory
private const long _highWaterMark = 0xA00000; // we would like to keep everything over 10 MB on disk
}
}
// 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
- ParseHttpDate.cs
- ScrollChrome.cs
- CompilerGeneratedAttribute.cs
- RegistryPermission.cs
- Part.cs
- QueryTaskGroupState.cs
- OleDbDataReader.cs
- StringWriter.cs
- PathTooLongException.cs
- HwndSource.cs
- ListViewTableCell.cs
- PnrpPermission.cs
- WebPartDisplayModeCancelEventArgs.cs
- UITypeEditor.cs
- _Semaphore.cs
- PropertyGroupDescription.cs
- UserThread.cs
- XamlGridLengthSerializer.cs
- XamlFrame.cs
- DataRelationCollection.cs
- ProfileGroupSettings.cs
- MsmqOutputMessage.cs
- URLMembershipCondition.cs
- WebDescriptionAttribute.cs
- RoleManagerSection.cs
- SingleAnimation.cs
- BaseCollection.cs
- XmlDocumentSerializer.cs
- EntityContainerAssociationSetEnd.cs
- CanonicalFontFamilyReference.cs
- COM2ColorConverter.cs
- LineGeometry.cs
- MenuItemCollection.cs
- DesignTimeVisibleAttribute.cs
- xml.cs
- PointConverter.cs
- ColumnBinding.cs
- CodeChecksumPragma.cs
- SymmetricAlgorithm.cs
- FlowDocumentReader.cs
- RectangleGeometry.cs
- GridProviderWrapper.cs
- ValueSerializer.cs
- AdvancedBindingEditor.cs
- WrapPanel.cs
- BulletChrome.cs
- MasterPageParser.cs
- HttpCacheVaryByContentEncodings.cs
- XmlWriterSettings.cs
- DependencyObject.cs
- RichTextBoxConstants.cs
- SystemResourceHost.cs
- AnimatedTypeHelpers.cs
- PageAsyncTaskManager.cs
- ObjectReferenceStack.cs
- ClientRuntimeConfig.cs
- SimpleHandlerBuildProvider.cs
- FusionWrap.cs
- PassportIdentity.cs
- ToolStripDropDownButton.cs
- OracleNumber.cs
- TextServicesHost.cs
- UxThemeWrapper.cs
- CodeTypeParameter.cs
- Timeline.cs
- SiteMapDesignerDataSourceView.cs
- FlowLayoutPanel.cs
- AbandonedMutexException.cs
- StringDictionary.cs
- TypeUnloadedException.cs
- _UncName.cs
- AnimationStorage.cs
- WsdlBuildProvider.cs
- NamedElement.cs
- FixedPageStructure.cs
- DateTimePicker.cs
- FixedSOMTableRow.cs
- Event.cs
- Int32AnimationUsingKeyFrames.cs
- GridPatternIdentifiers.cs
- FileEnumerator.cs
- Padding.cs
- TraceContextEventArgs.cs
- WebPartEditorCancelVerb.cs
- DefaultAssemblyResolver.cs
- DocumentProperties.cs
- DataListItem.cs
- LineGeometry.cs
- TransactionWaitAsyncResult.cs
- GetIndexBinder.cs
- IndexedGlyphRun.cs
- DataGridViewHitTestInfo.cs
- DefaultParameterValueAttribute.cs
- XmlSchemaAnnotated.cs
- WorkflowMessageEventHandler.cs
- GestureRecognitionResult.cs
- CodeDomSerializationProvider.cs
- Types.cs
- CompiledIdentityConstraint.cs
- DomainConstraint.cs