Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- RelatedImageListAttribute.cs
- ColorPalette.cs
- RotationValidation.cs
- ObjectCloneHelper.cs
- CheckBoxStandardAdapter.cs
- EventSetter.cs
- UrlPath.cs
- SizeChangedEventArgs.cs
- TypeForwardedToAttribute.cs
- Automation.cs
- SqlClientPermission.cs
- WmlPhoneCallAdapter.cs
- SecurityChannel.cs
- ExtensibleClassFactory.cs
- ViewCellSlot.cs
- EnumUnknown.cs
- Aggregates.cs
- CultureSpecificStringDictionary.cs
- PackageRelationshipCollection.cs
- querybuilder.cs
- WindowsFormsDesignerOptionService.cs
- HttpRawResponse.cs
- ToolBarTray.cs
- BasicBrowserDialog.cs
- InvalidCardException.cs
- SafeThreadHandle.cs
- _HTTPDateParse.cs
- ListBase.cs
- RSAPKCS1SignatureDeformatter.cs
- ManipulationDeltaEventArgs.cs
- QueryInterceptorAttribute.cs
- EventSourceCreationData.cs
- EntityDataSourceSelectedEventArgs.cs
- EmptyCollection.cs
- GridErrorDlg.cs
- MemberListBinding.cs
- CornerRadius.cs
- ModelFunctionTypeElement.cs
- RootBrowserWindowAutomationPeer.cs
- SafeNativeMethods.cs
- Function.cs
- _BasicClient.cs
- ControlIdConverter.cs
- HttpCapabilitiesBase.cs
- WebConfigurationHost.cs
- AutomationIdentifierGuids.cs
- FileDialog.cs
- ThemeConfigurationDialog.cs
- CultureInfoConverter.cs
- ReachPageContentCollectionSerializer.cs
- OpCodes.cs
- XPathExpr.cs
- XmlEnumAttribute.cs
- ColorAnimationUsingKeyFrames.cs
- UnaryNode.cs
- ListViewPagedDataSource.cs
- TableChangeProcessor.cs
- EntitySetBaseCollection.cs
- CfgParser.cs
- Rfc2898DeriveBytes.cs
- MenuDesigner.cs
- StrokeFIndices.cs
- _NegoState.cs
- XpsImage.cs
- ToolboxItemCollection.cs
- FixedBufferAttribute.cs
- FloaterParaClient.cs
- ReadOnlyCollectionBase.cs
- XmlReader.cs
- Figure.cs
- ObjectRef.cs
- TextTrailingCharacterEllipsis.cs
- GridToolTip.cs
- iisPickupDirectory.cs
- JsonStringDataContract.cs
- HashCodeCombiner.cs
- TransformerTypeCollection.cs
- ScrollProviderWrapper.cs
- VisualStyleRenderer.cs
- ConfigXmlAttribute.cs
- ActivationServices.cs
- AmbientLight.cs
- Validator.cs
- SafeFileMapViewHandle.cs
- MimePart.cs
- CompilationSection.cs
- OptimisticConcurrencyException.cs
- UITypeEditor.cs
- WebServiceParameterData.cs
- RuleEngine.cs
- ThousandthOfEmRealPoints.cs
- AuthStoreRoleProvider.cs
- DBCommand.cs
- ModelPerspective.cs
- StandardCommandToolStripMenuItem.cs
- AppDomainProtocolHandler.cs
- securestring.cs
- XamlStyleSerializer.cs
- AppDomain.cs
- Char.cs