Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Framework / System / Windows / Markup / BamlVersionHeader.cs / 1 / 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
- ConfigurationManagerInternal.cs
- XamlTemplateSerializer.cs
- SystemException.cs
- StrongNameHelpers.cs
- querybuilder.cs
- HashJoinQueryOperatorEnumerator.cs
- NameValueSectionHandler.cs
- WindowsTokenRoleProvider.cs
- StylusLogic.cs
- SizeConverter.cs
- externdll.cs
- WebEncodingValidator.cs
- LocalValueEnumerator.cs
- UshortList2.cs
- XmlSchemaType.cs
- AssociationEndMember.cs
- TextContainer.cs
- FormViewDeletedEventArgs.cs
- SafeIUnknown.cs
- SystemWebCachingSectionGroup.cs
- NameTable.cs
- ValidatorCollection.cs
- CompositeFontParser.cs
- RayHitTestParameters.cs
- ComboBoxDesigner.cs
- BezierSegment.cs
- MenuItemBinding.cs
- LinkClickEvent.cs
- SystemUnicastIPAddressInformation.cs
- MsmqMessageSerializationFormat.cs
- TreeSet.cs
- ConnectionPoolManager.cs
- AccessDataSourceView.cs
- RegistryExceptionHelper.cs
- XslAstAnalyzer.cs
- CaseInsensitiveComparer.cs
- FilePrompt.cs
- SliderAutomationPeer.cs
- DataGridViewCellPaintingEventArgs.cs
- ConsoleKeyInfo.cs
- OdbcConnectionFactory.cs
- SequentialOutput.cs
- CorrelationTokenInvalidatedHandler.cs
- XmlDataSourceNodeDescriptor.cs
- FragmentQueryKB.cs
- XsdCachingReader.cs
- ToolStripContextMenu.cs
- RoleService.cs
- ListViewEditEventArgs.cs
- XmlSchemaValidationException.cs
- X509AsymmetricSecurityKey.cs
- EntityStoreSchemaFilterEntry.cs
- IpcManager.cs
- DynamicPropertyHolder.cs
- OleDbRowUpdatedEvent.cs
- DbParameterHelper.cs
- ToolStripHighContrastRenderer.cs
- OptimalBreakSession.cs
- MultipartContentParser.cs
- TextPattern.cs
- DockPatternIdentifiers.cs
- TemplateNameScope.cs
- Marshal.cs
- ByteFacetDescriptionElement.cs
- listitem.cs
- CodeNamespaceImportCollection.cs
- OdbcRowUpdatingEvent.cs
- DaylightTime.cs
- XmlAnyElementAttribute.cs
- Accessible.cs
- DbTransaction.cs
- SqlUnionizer.cs
- SqlUserDefinedTypeAttribute.cs
- SqlGenerator.cs
- CheckBoxBaseAdapter.cs
- DefaultParameterValueAttribute.cs
- Label.cs
- CompModSwitches.cs
- SynchronizedDispatch.cs
- XPathNavigatorReader.cs
- BaseTemplateParser.cs
- WebServicesDescriptionAttribute.cs
- ProtectedConfiguration.cs
- UrlMapping.cs
- BuildManagerHost.cs
- HtmlTableRow.cs
- HttpCacheParams.cs
- StartUpEventArgs.cs
- DataSvcMapFileSerializer.cs
- NameScopePropertyAttribute.cs
- ClaimTypeRequirement.cs
- SqlCommand.cs
- PropertyEntry.cs
- CodeCommentStatementCollection.cs
- DashStyle.cs
- Brushes.cs
- UseLicense.cs
- TextServicesManager.cs
- FreeFormDragDropManager.cs
- DefaultMemberAttribute.cs