Code:
/ 4.0 / 4.0 / 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. // ==++== // // 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
- AlgoModule.cs
- StaticTextPointer.cs
- ADMembershipProvider.cs
- ConfigurationPropertyCollection.cs
- WebZone.cs
- DesignerVerb.cs
- DateTimeOffset.cs
- SupportsEventValidationAttribute.cs
- CqlLexerHelpers.cs
- LinqExpressionNormalizer.cs
- Matrix3DValueSerializer.cs
- ConfigXmlWhitespace.cs
- WebHttpSecurityElement.cs
- SchemaDeclBase.cs
- ModelUtilities.cs
- XPathDocumentIterator.cs
- StringHandle.cs
- MD5CryptoServiceProvider.cs
- RequestCacheValidator.cs
- XmlNodeReader.cs
- XamlSerializerUtil.cs
- PropertyRef.cs
- BamlBinaryReader.cs
- SQLMembershipProvider.cs
- LineSegment.cs
- NumberSubstitution.cs
- LockedActivityGlyph.cs
- TemplateBindingExpressionConverter.cs
- CompilerScopeManager.cs
- ViewValidator.cs
- PassportAuthenticationEventArgs.cs
- X509Certificate.cs
- TraceHandler.cs
- WindowInteropHelper.cs
- GridViewHeaderRowPresenter.cs
- XmlSchemaGroupRef.cs
- EventLogException.cs
- EffectiveValueEntry.cs
- IndexOutOfRangeException.cs
- BitmapEffectrendercontext.cs
- TreeViewDesigner.cs
- Rss20FeedFormatter.cs
- XPathScanner.cs
- SvcFileManager.cs
- FileEnumerator.cs
- DataTableNewRowEvent.cs
- Style.cs
- XmlWriterDelegator.cs
- RootAction.cs
- HttpServerUtilityWrapper.cs
- TrackingValidationObjectDictionary.cs
- SqlFileStream.cs
- AppSettingsExpressionBuilder.cs
- WorkflowWebHostingModule.cs
- InputProcessorProfiles.cs
- SQLConvert.cs
- Drawing.cs
- PrefixQName.cs
- HandlerBase.cs
- RootBuilder.cs
- ContextTokenTypeConverter.cs
- LineBreak.cs
- DefaultValidator.cs
- GifBitmapDecoder.cs
- DynamicPropertyReader.cs
- processwaithandle.cs
- Blend.cs
- odbcmetadatacolumnnames.cs
- DiscoveryCallbackBehavior.cs
- Int16Animation.cs
- ListSurrogate.cs
- SplashScreenNativeMethods.cs
- DataGridViewCellErrorTextNeededEventArgs.cs
- NotSupportedException.cs
- ArrayElementGridEntry.cs
- DynamicScriptObject.cs
- BufferedGraphicsContext.cs
- MembershipAdapter.cs
- assemblycache.cs
- ProxyHelper.cs
- AnnotationResourceChangedEventArgs.cs
- InfoCardListRequest.cs
- PerspectiveCamera.cs
- SQLResource.cs
- SetIterators.cs
- MetadataArtifactLoaderCompositeFile.cs
- ParameterReplacerVisitor.cs
- DocumentViewerConstants.cs
- _emptywebproxy.cs
- _BufferOffsetSize.cs
- WCFBuildProvider.cs
- ImmutableAssemblyCacheEntry.cs
- TabControl.cs
- DecoderBestFitFallback.cs
- SystemWebCachingSectionGroup.cs
- DeclarativeExpressionConditionDeclaration.cs
- HtmlTableRow.cs
- DbParameterCollection.cs
- EmptyReadOnlyDictionaryInternal.cs
- InsufficientMemoryException.cs