Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / System / IO / MemoryMappedFiles / MemoryMappedViewAccessor.cs / 1305376 / MemoryMappedViewAccessor.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: MemoryMappedViewAccessor ** ** Purpose: View accessor 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 MemoryMappedViewAccessor : UnmanagedMemoryAccessor { private MemoryMappedView m_view; //// [System.Security.SecurityCritical] internal MemoryMappedViewAccessor(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; } } //// // [System.Security.SecurityCritical] protected override void Dispose(bool disposing) { try { // Explicitly flush the changes. The OS will do this for us anyway, but not until after the // MemoryMappedFile object itself is closed. 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 void Flush() { if (!IsOpen) { throw new ObjectDisposedException("MemoryMappedViewAccessor", SR.GetString(SR.ObjectDisposed_ViewAccessorClosed)); } unsafe { if (m_view != null) { m_view.Flush((IntPtr)Capacity); } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: MemoryMappedViewAccessor ** ** Purpose: View accessor 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 MemoryMappedViewAccessor : UnmanagedMemoryAccessor { private MemoryMappedView m_view; //// // [System.Security.SecurityCritical] internal MemoryMappedViewAccessor(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; } } //// // [System.Security.SecurityCritical] protected override void Dispose(bool disposing) { try { // Explicitly flush the changes. The OS will do this for us anyway, but not until after the // MemoryMappedFile object itself is closed. 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 void Flush() { if (!IsOpen) { throw new ObjectDisposedException("MemoryMappedViewAccessor", SR.GetString(SR.ObjectDisposed_ViewAccessorClosed)); } 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
- ProcessHost.cs
- RangeValuePattern.cs
- DetailsViewDeletedEventArgs.cs
- ContentPresenter.cs
- UnicodeEncoding.cs
- DataGridCommandEventArgs.cs
- DetailsViewRow.cs
- TextServicesContext.cs
- ScaleTransform.cs
- MessageAction.cs
- DirectionalLight.cs
- AQNBuilder.cs
- XmlSignatureProperties.cs
- UniqueSet.cs
- StateBag.cs
- WinInetCache.cs
- UshortList2.cs
- SystemEvents.cs
- SortFieldComparer.cs
- CombinedGeometry.cs
- VectorAnimationBase.cs
- DefaultPrintController.cs
- ExtractorMetadata.cs
- HttpCachePolicy.cs
- TableCellCollection.cs
- ColumnTypeConverter.cs
- UriScheme.cs
- ContextMenu.cs
- ConfigurationElementProperty.cs
- SqlBulkCopyColumnMappingCollection.cs
- BindableTemplateBuilder.cs
- KerberosReceiverSecurityToken.cs
- FlowchartDesigner.Helpers.cs
- MemberDescriptor.cs
- StructuredType.cs
- BitmapSource.cs
- OrderedDictionary.cs
- ObjectHandle.cs
- RegisteredArrayDeclaration.cs
- ServiceBuildProvider.cs
- ArcSegment.cs
- CodeCastExpression.cs
- FlowDocumentView.cs
- ObjectConverter.cs
- FormViewUpdateEventArgs.cs
- Size.cs
- DoubleAnimationUsingPath.cs
- RepeaterCommandEventArgs.cs
- ExceptionValidationRule.cs
- SafeNativeMethods.cs
- BmpBitmapEncoder.cs
- DataTemplate.cs
- ScriptingProfileServiceSection.cs
- DataRelation.cs
- ADMembershipProvider.cs
- FlowSwitchLink.cs
- PixelFormats.cs
- GetIsBrowserClientRequest.cs
- DocComment.cs
- CodeSnippetCompileUnit.cs
- MethodSignatureGenerator.cs
- WindowsGraphicsCacheManager.cs
- FindCriteria11.cs
- ConnectionPoint.cs
- SqlConnectionPoolProviderInfo.cs
- validationstate.cs
- FlowDocumentPage.cs
- XmlCharType.cs
- Rect3DValueSerializer.cs
- XPathAncestorQuery.cs
- HwndSource.cs
- ActivityMarkupSerializationProvider.cs
- FormViewUpdateEventArgs.cs
- ObjectAnimationBase.cs
- DataListItemEventArgs.cs
- ResourceContainer.cs
- MarginCollapsingState.cs
- TextBoxLine.cs
- DataControlFieldCell.cs
- DataGridViewColumnEventArgs.cs
- RayMeshGeometry3DHitTestResult.cs
- LinqDataSourceContextEventArgs.cs
- WebHttpSecurityModeHelper.cs
- ChildDocumentBlock.cs
- PathGeometry.cs
- SqlRowUpdatingEvent.cs
- PointConverter.cs
- ListArgumentProvider.cs
- ButtonFieldBase.cs
- DataListDesigner.cs
- WebPartZone.cs
- EntityDataSourceMemberPath.cs
- Int32CAMarshaler.cs
- MessageBox.cs
- StateMachineExecutionState.cs
- SqlServer2KCompatibilityCheck.cs
- SoapCodeExporter.cs
- EntityException.cs
- BuildProvider.cs
- Maps.cs