Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / System / IO / MemoryMappedFiles / MemoryMappedViewStream.cs / 1305376 / MemoryMappedViewStream.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: MemoryMappedViewStream ** ** Purpose: View stream for managed MemoryMappedFiles. ** ** Date: February 7, 2007 ** ===========================================================*/ using System; using System.Diagnostics; using System.Security.Permissions; using Microsoft.Win32.SafeHandles; namespace System.IO.MemoryMappedFiles { public sealed class MemoryMappedViewStream : UnmanagedMemoryStream { private MemoryMappedView m_view; //// [System.Security.SecurityCritical] internal unsafe MemoryMappedViewStream(MemoryMappedView view) { Debug.Assert(view != null, "view is null"); m_view = view; Initialize(m_view.ViewHandle, m_view.PointerOffset, m_view.Size, MemoryMappedFile.GetFileAccess(m_view.Access)); } public SafeMemoryMappedViewHandle SafeMemoryMappedViewHandle { //// // [System.Security.SecurityCritical] [SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)] get { return m_view != null ? m_view.ViewHandle : null; } } public override void SetLength(long value) { throw new NotSupportedException(SR.GetString(SR.NotSupported_MMViewStreamsFixedLength)); } //// // [System.Security.SecurityCritical] protected override void Dispose(bool disposing) { try { if (disposing && m_view != null && !m_view.IsClosed) { Flush(); } } finally { try { if (m_view != null) { m_view.Dispose(); } } finally { base.Dispose(disposing); } } } // Flushes the changes such that they are in [....] with the FileStream bits (ones obtained // with the win32 ReadFile and WriteFile functions). Need to call FileStream's Flush to // flush to the disk. // NOTE: This will flush all bytes before and after the view up until an offset that is a // multiple of SystemPageSize. //// // [System.Security.SecurityCritical] public override void Flush() { if (!CanSeek) { __Error.StreamIsClosed(); } unsafe { if (m_view != null) { m_view.Flush((IntPtr)Capacity); } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.//
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XmlReflectionImporter.cs
- HeaderedItemsControl.cs
- ConfigXmlWhitespace.cs
- SQLInt64Storage.cs
- XmlTextReaderImplHelpers.cs
- XDRSchema.cs
- SoapHttpTransportImporter.cs
- SqlUtils.cs
- JavaScriptObjectDeserializer.cs
- ColorAnimationBase.cs
- SqlClientPermission.cs
- HostDesigntimeLicenseContext.cs
- DataRecordInternal.cs
- Divide.cs
- Relationship.cs
- ViewValidator.cs
- DataGridViewCellConverter.cs
- CompilerError.cs
- AsymmetricAlgorithm.cs
- TraceInternal.cs
- InvalidAsynchronousStateException.cs
- ExceptionValidationRule.cs
- NamespaceDecl.cs
- ByteStream.cs
- InputMethod.cs
- WindowsTab.cs
- InputProcessorProfiles.cs
- IPAddress.cs
- _FtpDataStream.cs
- SqlDataSourceFilteringEventArgs.cs
- Encoder.cs
- XmlChoiceIdentifierAttribute.cs
- ValueOfAction.cs
- DbConnectionFactory.cs
- CacheModeConverter.cs
- PasswordDeriveBytes.cs
- FontCollection.cs
- securitymgrsite.cs
- SqlExpressionNullability.cs
- MouseActionConverter.cs
- LogReservationCollection.cs
- MoveSizeWinEventHandler.cs
- ModelPerspective.cs
- RelationshipType.cs
- HttpStreams.cs
- VisualStyleRenderer.cs
- ExceptionUtil.cs
- TypeBuilder.cs
- TextTreeInsertUndoUnit.cs
- FlowDocumentFormatter.cs
- XmlElementAttributes.cs
- OrderPreservingPipeliningMergeHelper.cs
- ReadOnlyCollectionBase.cs
- XmlSerializationWriter.cs
- CommandBinding.cs
- ProviderBase.cs
- SelectionRangeConverter.cs
- SemanticResultValue.cs
- KeyValuePairs.cs
- HostedBindingBehavior.cs
- ObjectQuery.cs
- NavigationCommands.cs
- IgnoreSectionHandler.cs
- SelectedGridItemChangedEvent.cs
- DateTimeStorage.cs
- ReferenceConverter.cs
- SqlTopReducer.cs
- WeakReferenceEnumerator.cs
- GACIdentityPermission.cs
- ConsoleCancelEventArgs.cs
- EmptyReadOnlyDictionaryInternal.cs
- EastAsianLunisolarCalendar.cs
- ClientSettingsSection.cs
- DnsPermission.cs
- ClusterUtils.cs
- NegotiationTokenProvider.cs
- LockRenewalTask.cs
- JsonFormatWriterGenerator.cs
- DynamicDiscoveryDocument.cs
- ServicePoint.cs
- ModelUIElement3D.cs
- XmlHierarchicalEnumerable.cs
- SymmetricAlgorithm.cs
- Registry.cs
- CacheAxisQuery.cs
- ToolStripSettings.cs
- DbCommandDefinition.cs
- UInt32Storage.cs
- ArgumentNullException.cs
- ToolboxItemAttribute.cs
- IHttpResponseInternal.cs
- PageWrapper.cs
- HealthMonitoringSectionHelper.cs
- MessageSmuggler.cs
- StringConverter.cs
- WindowsIdentity.cs
- Merger.cs
- BitmapEffectInput.cs
- SignatureResourceHelper.cs
- ServicePointManager.cs