Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / Log / System / IO / Log / LogArchiveSnapshot.cs / 1 / LogArchiveSnapshot.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.IO.Log { using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; public sealed class LogArchiveSnapshot { SequenceNumber archiveTail; SequenceNumber baseSequenceNumber; SequenceNumber lastSequenceNumber; IEnumerableregions; const int MaxFileNameLength = 260; internal LogArchiveSnapshot(LogStore store, ulong lsnLow, ulong lsnHigh) { StringBuilder baseLogFileName = new StringBuilder(MaxFileNameLength); int actualLength; ulong baseLogFileOffset; ulong baseLogFileLength; ulong lsnBase; ulong lsnLast; ulong lsnArchiveTail; SafeArchiveContext archiveContext = null; try { while (!UnsafeNativeMethods.PrepareLogArchive( store.Handle, baseLogFileName, baseLogFileName.Capacity, ref lsnLow, ref lsnHigh, out actualLength, out baseLogFileOffset, out baseLogFileLength, out lsnBase, out lsnLast, out lsnArchiveTail, out archiveContext)) { baseLogFileName.EnsureCapacity(actualLength+1); } this.archiveTail = new SequenceNumber(lsnArchiveTail); this.baseSequenceNumber = new SequenceNumber(lsnBase); this.lastSequenceNumber = new SequenceNumber(lsnLast); List regions = new List (); byte[] readBuffer = new byte[checked((uint)baseLogFileLength)]; uint actualDataLength = 0; unsafe { fixed(byte *pbReadBuffer = readBuffer) { UnsafeNativeMethods.ReadLogArchiveMetadata( archiveContext, 0, readBuffer.Length, pbReadBuffer, out actualDataLength); } } byte[] baseFileData; if (actualDataLength == (uint)baseLogFileLength) { baseFileData = readBuffer; } else { baseFileData = new byte[actualDataLength]; Array.Copy(readBuffer, baseFileData, baseFileData.Length); } regions.Add(new FileRegion((long)baseLogFileLength, baseLogFileName.ToString(), (long)baseLogFileOffset, baseFileData)); CLFS_ARCHIVE_DESCRIPTOR descriptor = new CLFS_ARCHIVE_DESCRIPTOR(); while(true) { int returnedCount; if (!UnsafeNativeMethods.GetNextLogArchiveExtentSingle( archiveContext, ref descriptor, out returnedCount)) { break; } if (returnedCount < 1) break; long start = checked((long)descriptor.coffLow); long length = checked((long)(descriptor.coffHigh - descriptor.coffLow)); string fileName = descriptor.infoContainer.GetActualFileName(store.Handle); FileInfo containerInfo; containerInfo = new FileInfo(fileName); regions.Add(new FileRegion(containerInfo.Length, fileName, start, length)); } this.regions = regions.AsReadOnly(); } finally { if (archiveContext != null && !archiveContext.IsInvalid) { archiveContext.Close(); } } } public IEnumerable ArchiveRegions { get { return this.regions; } } public SequenceNumber ArchiveTail { get { return this.archiveTail; } } public SequenceNumber BaseSequenceNumber { get { return this.baseSequenceNumber; } } public SequenceNumber LastSequenceNumber { get { return this.lastSequenceNumber; } } } } // 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
- ServicesUtilities.cs
- FixedFlowMap.cs
- TrustSection.cs
- TextSelection.cs
- AutomationIdentifier.cs
- ZipPackage.cs
- ToolTipService.cs
- EmptyEnumerator.cs
- RegistryPermission.cs
- ControlLocalizer.cs
- PropertyPathWorker.cs
- MembershipUser.cs
- NativeCppClassAttribute.cs
- LicenseProviderAttribute.cs
- ColumnResizeAdorner.cs
- PathParser.cs
- SystemInfo.cs
- DelegatingTypeDescriptionProvider.cs
- AssemblyCache.cs
- _TLSstream.cs
- FileDialogCustomPlacesCollection.cs
- Transform3DGroup.cs
- cookie.cs
- TypeDependencyAttribute.cs
- QilPatternVisitor.cs
- ChildDocumentBlock.cs
- NCryptSafeHandles.cs
- SafeCryptoHandles.cs
- ComponentResourceKeyConverter.cs
- ImageListImageEditor.cs
- ListBoxAutomationPeer.cs
- DefaultConfirmation.cs
- WaitHandle.cs
- XmlException.cs
- WaitHandle.cs
- TextWriterTraceListener.cs
- GridErrorDlg.cs
- mediaclock.cs
- StateWorkerRequest.cs
- FaultException.cs
- XmlIncludeAttribute.cs
- DrawingContextWalker.cs
- EventSinkHelperWriter.cs
- ObjectToIdCache.cs
- UpdatePanelTrigger.cs
- NamespaceEmitter.cs
- DataSetUtil.cs
- Nodes.cs
- OleDbError.cs
- SingleResultAttribute.cs
- ListChangedEventArgs.cs
- RegistrySecurity.cs
- CrossAppDomainChannel.cs
- TreeNodeBindingDepthConverter.cs
- _LazyAsyncResult.cs
- DesignerDataTable.cs
- SpeechAudioFormatInfo.cs
- XmlKeywords.cs
- Margins.cs
- TextCharacters.cs
- Hash.cs
- ToolStripSplitButton.cs
- TripleDESCryptoServiceProvider.cs
- DataGridViewColumnEventArgs.cs
- MsmqIntegrationAppDomainProtocolHandler.cs
- TabPage.cs
- EntityStoreSchemaFilterEntry.cs
- StatusBarPanelClickEvent.cs
- RoutedEventValueSerializer.cs
- XmlFormatExtensionPointAttribute.cs
- OdbcErrorCollection.cs
- HostExecutionContextManager.cs
- XmlSchemaAnyAttribute.cs
- Camera.cs
- DataKeyPropertyAttribute.cs
- CodeParameterDeclarationExpression.cs
- CanonicalizationDriver.cs
- TypeConvertions.cs
- Int32CAMarshaler.cs
- ItemChangedEventArgs.cs
- CompletedAsyncResult.cs
- Journal.cs
- NameSpaceEvent.cs
- XmlImplementation.cs
- ComPlusAuthorization.cs
- InputLangChangeEvent.cs
- FileAuthorizationModule.cs
- AbsoluteQuery.cs
- PersonalizationEntry.cs
- HandlerWithFactory.cs
- AmbientValueAttribute.cs
- PropertyPushdownHelper.cs
- OdbcRowUpdatingEvent.cs
- VarRefManager.cs
- WebDisplayNameAttribute.cs
- CommandPlan.cs
- UpdatePanelTriggerCollection.cs
- SafeMemoryMappedViewHandle.cs
- _HelperAsyncResults.cs
- AnnotationStore.cs