Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Markup / BamlVersionHeader.cs / 1305600 / BamlVersionHeader.cs
/****************************************************************************\ * * File: BamlVersionHeader.cs * * Copyright (C) 2005 by Microsoft Corporation. All rights reserved. * \***************************************************************************/ using System; using System.IO; using System.Globalization; using System.Diagnostics; using MS.Internal.IO.Packaging.CompoundFile; #if PBTCOMPILER namespace MS.Internal.Markup #else namespace System.Windows.Markup #endif { internal class BamlVersionHeader { // The current BAML record version. This is incremented whenever // the BAML format changes // Baml Format Breaking Changes should change this. internal static readonly VersionPair BamlWriterVersion; static BamlVersionHeader() { // Initialize the Version number this way so that it can be // seen in the Lutz Reflector. BamlWriterVersion = new VersionPair(0, 96); } public BamlVersionHeader() { _bamlVersion = new FormatVersion("MSBAML", BamlWriterVersion); } public FormatVersion BamlVersion { get { return _bamlVersion; } #if !PBTCOMPILER set { _bamlVersion = value; } #endif } // This is used by Async loading to measure if the whole record is present static public int BinarySerializationSize { get { // Unicode "MSBAML" = 12 // + 4 bytes length header = 12 + 4 = 16 // + 3*(16bit MinorVer + 16bit MajorVer) = 16+(3*(2+2))= 28 // For product stability the size of this data structure // shouldn't change anyway. return 28; } } #if !PBTCOMPILER internal void LoadVersion(BinaryReader bamlBinaryReader) { #if DEBUG long posStart = bamlBinaryReader.BaseStream.Position; #endif BamlVersion = FormatVersion.LoadFromStream(bamlBinaryReader.BaseStream); #if DEBUG long posEnd = bamlBinaryReader.BaseStream.Position; Debug.Assert((posEnd-posStart) == BamlVersionHeader.BinarySerializationSize, "Incorrect Baml Version Header Size"); #endif // We're assuming that only major versions are significant for compatibility, // so if we have a major version in the file that is higher than that in // the code, we can't read it. if (BamlVersion.ReaderVersion != BamlWriterVersion) { throw new InvalidOperationException(SR.Get(SRID.ParserBamlVersion, (BamlVersion.ReaderVersion.Major.ToString(CultureInfo.CurrentCulture) + "." + BamlVersion.ReaderVersion.Minor.ToString(CultureInfo.CurrentCulture)), (BamlWriterVersion.Major.ToString(CultureInfo.CurrentCulture) + "." + BamlWriterVersion.Minor.ToString(CultureInfo.CurrentCulture)))); } } #endif internal void WriteVersion(BinaryWriter bamlBinaryWriter) { #if DEBUG long posStart = bamlBinaryWriter.BaseStream.Position; #endif BamlVersion.SaveToStream(bamlBinaryWriter.BaseStream); #if DEBUG long posEnd = bamlBinaryWriter.BaseStream.Position; if(-1 == posStart) { long length = bamlBinaryWriter.BaseStream.Length; Debug.Assert(length == BamlVersionHeader.BinarySerializationSize, "Incorrect Baml Version Header Size"); } else { Debug.Assert((posEnd-posStart) == BamlVersionHeader.BinarySerializationSize, "Incorrect Baml Version Header Size"); } #endif } FormatVersion _bamlVersion; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. /****************************************************************************\ * * File: BamlVersionHeader.cs * * Copyright (C) 2005 by Microsoft Corporation. All rights reserved. * \***************************************************************************/ using System; using System.IO; using System.Globalization; using System.Diagnostics; using MS.Internal.IO.Packaging.CompoundFile; #if PBTCOMPILER namespace MS.Internal.Markup #else namespace System.Windows.Markup #endif { internal class BamlVersionHeader { // The current BAML record version. This is incremented whenever // the BAML format changes // Baml Format Breaking Changes should change this. internal static readonly VersionPair BamlWriterVersion; static BamlVersionHeader() { // Initialize the Version number this way so that it can be // seen in the Lutz Reflector. BamlWriterVersion = new VersionPair(0, 96); } public BamlVersionHeader() { _bamlVersion = new FormatVersion("MSBAML", BamlWriterVersion); } public FormatVersion BamlVersion { get { return _bamlVersion; } #if !PBTCOMPILER set { _bamlVersion = value; } #endif } // This is used by Async loading to measure if the whole record is present static public int BinarySerializationSize { get { // Unicode "MSBAML" = 12 // + 4 bytes length header = 12 + 4 = 16 // + 3*(16bit MinorVer + 16bit MajorVer) = 16+(3*(2+2))= 28 // For product stability the size of this data structure // shouldn't change anyway. return 28; } } #if !PBTCOMPILER internal void LoadVersion(BinaryReader bamlBinaryReader) { #if DEBUG long posStart = bamlBinaryReader.BaseStream.Position; #endif BamlVersion = FormatVersion.LoadFromStream(bamlBinaryReader.BaseStream); #if DEBUG long posEnd = bamlBinaryReader.BaseStream.Position; Debug.Assert((posEnd-posStart) == BamlVersionHeader.BinarySerializationSize, "Incorrect Baml Version Header Size"); #endif // We're assuming that only major versions are significant for compatibility, // so if we have a major version in the file that is higher than that in // the code, we can't read it. if (BamlVersion.ReaderVersion != BamlWriterVersion) { throw new InvalidOperationException(SR.Get(SRID.ParserBamlVersion, (BamlVersion.ReaderVersion.Major.ToString(CultureInfo.CurrentCulture) + "." + BamlVersion.ReaderVersion.Minor.ToString(CultureInfo.CurrentCulture)), (BamlWriterVersion.Major.ToString(CultureInfo.CurrentCulture) + "." + BamlWriterVersion.Minor.ToString(CultureInfo.CurrentCulture)))); } } #endif internal void WriteVersion(BinaryWriter bamlBinaryWriter) { #if DEBUG long posStart = bamlBinaryWriter.BaseStream.Position; #endif BamlVersion.SaveToStream(bamlBinaryWriter.BaseStream); #if DEBUG long posEnd = bamlBinaryWriter.BaseStream.Position; if(-1 == posStart) { long length = bamlBinaryWriter.BaseStream.Length; Debug.Assert(length == BamlVersionHeader.BinarySerializationSize, "Incorrect Baml Version Header Size"); } else { Debug.Assert((posEnd-posStart) == BamlVersionHeader.BinarySerializationSize, "Incorrect Baml Version Header Size"); } #endif } FormatVersion _bamlVersion; } } // 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
- PathNode.cs
- CompilationRelaxations.cs
- EpmContentDeSerializerBase.cs
- ByteAnimationUsingKeyFrames.cs
- XpsS0ValidatingLoader.cs
- HashCodeCombiner.cs
- CustomPopupPlacement.cs
- ASCIIEncoding.cs
- BlurBitmapEffect.cs
- TextBoxAutoCompleteSourceConverter.cs
- SqlMethods.cs
- DataAdapter.cs
- DbProviderSpecificTypePropertyAttribute.cs
- PaintValueEventArgs.cs
- X509Chain.cs
- ResponseStream.cs
- MulticastOption.cs
- InternalsVisibleToAttribute.cs
- XmlSerializableWriter.cs
- WindowsHyperlink.cs
- DocumentViewerHelper.cs
- DynamicMethod.cs
- InputManager.cs
- EntityKeyElement.cs
- ProcessRequestArgs.cs
- XmlWhitespace.cs
- WebPartTransformerAttribute.cs
- LocationSectionRecord.cs
- DefaultAuthorizationContext.cs
- WebPartZone.cs
- Stack.cs
- PrePrepareMethodAttribute.cs
- RoleBoolean.cs
- IndexedString.cs
- DirectionalLight.cs
- AnimationClockResource.cs
- FormatConvertedBitmap.cs
- ADConnectionHelper.cs
- RowToParametersTransformer.cs
- OverrideMode.cs
- MailWebEventProvider.cs
- ChildrenQuery.cs
- ImageSourceValueSerializer.cs
- EvidenceBase.cs
- MarkupObject.cs
- ObjectSet.cs
- RepeaterItem.cs
- DataObject.cs
- FileLogRecordHeader.cs
- Msmq4SubqueuePoisonHandler.cs
- SafeCryptoKeyHandle.cs
- Overlapped.cs
- WebPartCancelEventArgs.cs
- WorkflowPrinting.cs
- RawStylusSystemGestureInputReport.cs
- RegexMatchCollection.cs
- IntSecurity.cs
- DataGridViewTopRowAccessibleObject.cs
- SqlExpander.cs
- _LoggingObject.cs
- DocComment.cs
- WebPartConnectionsConfigureVerb.cs
- HwndTarget.cs
- IDReferencePropertyAttribute.cs
- SortQuery.cs
- ControlSerializer.cs
- Int16AnimationBase.cs
- WindowsListViewItemCheckBox.cs
- InstanceHandleReference.cs
- RecordsAffectedEventArgs.cs
- UIElement.cs
- NetworkAddressChange.cs
- UIPermission.cs
- ListViewTableRow.cs
- MulticastNotSupportedException.cs
- Substitution.cs
- SuppressIldasmAttribute.cs
- RepeaterItemCollection.cs
- hresults.cs
- DataRow.cs
- SQLBinaryStorage.cs
- SspiNegotiationTokenAuthenticatorState.cs
- PathFigure.cs
- ProtocolException.cs
- ObjectConverter.cs
- MobileComponentEditorPage.cs
- StrongName.cs
- MembershipSection.cs
- PerfService.cs
- CFGGrammar.cs
- DbMetaDataFactory.cs
- BinaryObjectWriter.cs
- Win32.cs
- AddInDeploymentState.cs
- GridViewUpdateEventArgs.cs
- XhtmlMobileTextWriter.cs
- XsdDateTime.cs
- XmlSignatureManifest.cs
- LoginName.cs
- MSAAEventDispatcher.cs